66
77
88def handler (event , context ):
9+ if verify_supported_media_type (event ['headers' ]) is False :
10+ return response_builder (415 , {
11+ 'error_message' : "This API only support 'content-type: application/x-www-form-urlencoded' media type"
12+ })
13+
914 token = {}
1015
11- try :
12- if verify_supported_media_type (event ['headers' ]) is False :
13- return response_builder (415 , {
14- 'error_message' : "This API only support 'content-type: application/x-www-form-urlencoded' media type"
15- })
16+ authlete = AuthleteSdk (
17+ api_key = os .environ ['AUTHLETE_API_KEY' ],
18+ api_secret = os .environ ['AUTHLETE_API_SECRET' ]
19+ )
1620
17- authlete = AuthleteSdk (
18- api_key = os .environ ['AUTHLETE_API_KEY' ],
19- api_secret = os .environ ['AUTHLETE_API_SECRET' ]
20- )
21+ try :
22+ # トークン取得処理
2123
2224 grant_type = authlete .get_grant_type (
2325 body = event ['body' ]
@@ -28,7 +30,6 @@ def handler(event, context):
2830 body = event ['body' ]
2931 )
3032
31- # トークン取得処理
3233 if grant_type == 'authorization_code' :
3334 if data .get ('client_secret' ) is None :
3435 token = authlete .get_access_token_from_code (
@@ -77,11 +78,6 @@ def handler(event, context):
7778 user_pool_id = os .environ ['COGNITO_USER_POOL_ID' ]
7879 )
7980
80- authlete = AuthleteSdk (
81- api_key = os .environ ['AUTHLETE_API_KEY' ],
82- api_secret = os .environ ['AUTHLETE_API_SECRET' ]
83- )
84-
8581 access_token = token .get ('access_token' )
8682 response_content = authlete .get_user_info (access_token = access_token )
8783 attributes = congito_user_pool .get_user_attributes (username = response_content ['sub' ])
0 commit comments