| 75 | |
| 76 | |
| 77 | def do_sso_login( |
| 78 | session, |
| 79 | sso_region, |
| 80 | start_url, |
| 81 | parsed_globals, |
| 82 | token_cache=None, |
| 83 | on_pending_authorization=None, |
| 84 | force_refresh=False, |
| 85 | registration_scopes=None, |
| 86 | session_name=None, |
| 87 | use_device_code=False, |
| 88 | resolved_start_url=None, |
| 89 | ): |
| 90 | if token_cache is None: |
| 91 | token_cache = JSONFileCache(SSO_TOKEN_DIR, dumps_func=_sso_json_dumps) |
| 92 | if on_pending_authorization is None: |
| 93 | on_pending_authorization = OpenBrowserHandler( |
| 94 | open_browser=open_browser_with_original_ld_path |
| 95 | ) |
| 96 | |
| 97 | # For the auth flow, we need a non-legacy sso-session and check that the |
| 98 | # user hasn't opted into falling back to the device code flow |
| 99 | if session_name and not use_device_code: |
| 100 | token_fetcher = SSOTokenFetcherAuth( |
| 101 | sso_region=sso_region, |
| 102 | client_creator=session.create_client, |
| 103 | parsed_globals=parsed_globals, |
| 104 | auth_code_fetcher=AuthCodeFetcher(), |
| 105 | cache=token_cache, |
| 106 | on_pending_authorization=on_pending_authorization, |
| 107 | ) |
| 108 | else: |
| 109 | token_fetcher = SSOTokenFetcher( |
| 110 | sso_region=sso_region, |
| 111 | client_creator=session.create_client, |
| 112 | parsed_globals=parsed_globals, |
| 113 | cache=token_cache, |
| 114 | on_pending_authorization=on_pending_authorization, |
| 115 | ) |
| 116 | |
| 117 | return token_fetcher.fetch_token( |
| 118 | start_url=start_url, |
| 119 | session_name=session_name, |
| 120 | force_refresh=force_refresh, |
| 121 | registration_scopes=registration_scopes, |
| 122 | resolved_start_url=resolved_start_url, |
| 123 | ) |
| 124 | |
| 125 | |
| 126 | def parse_sso_registration_scopes(raw_scopes): |