MCPcopy
hub / github.com/spotipy-dev/spotipy / get_access_token

Method get_access_token

spotipy/oauth2.py:1095–1119  ·  view source on GitHub ↗

Gets Auth Token from cache (preferred) or user interaction Parameters ---------- * state: May be given, overrides (without changing) self.state * response: URI with token, can break expiration checks * check_cache: Interpreted as boolean

(self,
                         state=None,
                         response=None,
                         check_cache=True)

Source from the content-addressed store, hash-verified

1093 return token_info
1094
1095 def get_access_token(self,
1096 state=None,
1097 response=None,
1098 check_cache=True):
1099 """ Gets Auth Token from cache (preferred) or user interaction
1100
1101 Parameters
1102 ----------
1103 * state: May be given, overrides (without changing) self.state
1104 * response: URI with token, can break expiration checks
1105 * check_cache: Interpreted as boolean
1106 """
1107 if check_cache:
1108 token_info = self.validate_token(self.cache_handler.get_cached_token())
1109 if not (token_info is None or self.is_token_expired(token_info)):
1110 return token_info["access_token"]
1111
1112 if response:
1113 token_info = self.parse_response_token(response)
1114 else:
1115 token_info = self.get_auth_response(state)
1116 token_info = self._add_custom_values_to_token_info(token_info)
1117 self.cache_handler.save_token_to_cache(token_info)
1118
1119 return token_info["access_token"]
1120
1121 def get_authorize_url(self, state=None):
1122 """ Gets the URL to use to authorize this app """

Callers

nothing calls this directly

Calls 7

validate_tokenMethod · 0.95
parse_response_tokenMethod · 0.95
get_auth_responseMethod · 0.95
is_token_expiredMethod · 0.80
get_cached_tokenMethod · 0.45
save_token_to_cacheMethod · 0.45

Tested by

no test coverage detected