MCPcopy Create free account
hub / github.com/aws/aws-cli / fetch_token

Method fetch_token

awscli/customizations/login/utils.py:273–308  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

271 """
272
273 def fetch_token(self):
274 register_feature_id('LOGIN_CROSS_DEVICE')
275 redirect_uri = f'{self._base_endpoint}/v1/sessions/confirmation'
276
277 authorization_uri = self._get_authorization_uri(
278 client_id=CLIENT_ID[LoginType.CROSS_DEVICE],
279 expected_state=self._expected_state,
280 code_challenge=self._code_challenge,
281 redirect_uri=redirect_uri,
282 )
283
284 self._on_pending_authorization(
285 **self._get_browser_handler_args(authorization_uri)
286 )
287
288 verification_code = self._prompt(
289 '\nEnter the authorization code displayed in your browser'
290 )
291
292 auth_code, state = self.parse_verification_code(verification_code)
293
294 if auth_code is None:
295 raise LoginAuthorizationCodeError(
296 error_msg='Failed to retrieve an authorization code.'
297 )
298
299 if state != str(self._expected_state):
300 raise LoginAuthorizationCodeError(
301 error_msg=f'State parameter {state} does not match expected value {self._expected_state}.'
302 )
303
304 return self._exchange_auth_code_for_access_token(
305 client_id=CLIENT_ID[LoginType.CROSS_DEVICE],
306 auth_code=auth_code,
307 redirect_uri=redirect_uri,
308 )
309
310 @staticmethod
311 def parse_verification_code(verification_code):

Callers 1

_run_mainMethod · 0.95

Calls 7

_promptMethod · 0.95
register_feature_idFunction · 0.90

Tested by

no test coverage detected