1 """Provide oauth implementations for the Tesla Fleet integration."""
16 from .const
import AUTHORIZE_URL, CLIENT_ID, DOMAIN, SCOPES, TOKEN_URL
20 """Tesla Fleet API open source Oauth2 implementation."""
25 def __init__(self, hass: HomeAssistant) ->
None:
26 """Initialize open source Oauth2 implementation."""
30 hashed_verifier = hashlib.sha256(self.
code_verifiercode_verifier.encode()).digest()
32 base64.urlsafe_b64encode(hashed_verifier).decode().replace(
"=",
"")
45 """Name of the implementation."""
46 return "Built-in open source client ID"
50 """Extra data that needs to be appended to the authorize url."""
53 "scope":
" ".join(SCOPES),
58 """Resolve the authorization code to tokens."""
59 return await self._token_request(
61 "grant_type":
"authorization_code",
62 "code": external_data[
"code"],
63 "redirect_uri": external_data[
"state"][
"redirect_uri"],
70 """Tesla Fleet API user Oauth2 implementation."""
73 self, hass: HomeAssistant, auth_domain: str, credential: ClientCredential
75 """Initialize user Oauth2 implementation."""
86 """Extra data that needs to be appended to the authorize url."""
87 return {
"prompt":
"login",
"scope":
" ".join(SCOPES)}
dict[str, Any] extra_authorize_data(self)
dict async_resolve_external_data(self, Any external_data)
None __init__(self, HomeAssistant hass)
None __init__(self, HomeAssistant hass, str auth_domain, ClientCredential credential)
dict[str, Any] extra_authorize_data(self)