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

Method _run_main

awscli/customizations/login/login.py:87–154  ·  view source on GitHub ↗
(self, parsed_args, parsed_globals)

Source from the content-addressed store, hash-verified

85 self._config_file_writer = config_file_writer
86
87 def _run_main(self, parsed_args, parsed_globals):
88 region = self._resolve_region(parsed_globals)
89 profile_name = self.resolve_profile_name()
90 sign_in_type = self.resolve_sign_in_type(parsed_args)
91
92 # If the profile specified via --profile doesn't already exist
93 # add it to the session so the client creation still succeeds.
94 # If the login is successful we'll save the profile at the end.
95 if profile_name not in self._session.available_profiles:
96 self._session._profile_map[profile_name] = {}
97
98 # Abort if the profile is already configured with a different style
99 # of credentials, since they'd still have precedence over login
100 self.ensure_profile_does_not_have_existing_credentials(profile_name)
101
102 config = botocore.config.Config(
103 region_name=region,
104 signature_version=botocore.UNSIGNED,
105 )
106 client = self._session.create_client(
107 'signin',
108 config=config,
109 endpoint_url=parsed_globals.endpoint_url,
110 verify=parsed_globals.verify_ssl,
111 )
112
113 private_key = EC.new_generate(ECType.P_256)
114
115 if sign_in_type is LoginType.SAME_DEVICE:
116 token_fetcher = SameDeviceLoginTokenFetcher(
117 client=client,
118 auth_code_fetcher=AuthCodeFetcher(),
119 on_pending_authorization=OpenBrowserHandler(
120 open_browser=open_browser_with_original_ld_path
121 ),
122 private_key=private_key,
123 )
124 else: # Cross-Device
125 token_fetcher = CrossDeviceLoginTokenFetcher(
126 client=client,
127 on_pending_authorization=PrintOnlyHandler(),
128 private_key=private_key,
129 )
130
131 # Execute the browser flow, and the initial call to the token endpoint
132 access_token, session_id = token_fetcher.fetch_token()
133
134 if not self.accept_change_to_existing_profile_if_needed(
135 profile_name, session_id
136 ):
137 return
138
139 # Cache the access token to disk
140 self._token_loader.save_token(session_id, access_token)
141
142 # Update the specified profile with the session (and region if not set)
143 self._update_profile_with_login_session(
144 profile_name, session_id, region

Callers

nothing calls this directly

Tested by

no test coverage detected