1 """oAuth2 functions and classes for Geocaching API integration."""
3 from __future__
import annotations
14 from .const
import ENVIRONMENT, ENVIRONMENT_URLS
18 """Local OAuth2 implementation for Geocaching."""
24 credential: ClientCredential,
26 """Local Geocaching Oauth Implementation."""
29 auth_domain=auth_domain,
30 credential=credential,
32 authorize_url=ENVIRONMENT_URLS[ENVIRONMENT][
"authorize_url"],
33 token_url=ENVIRONMENT_URLS[ENVIRONMENT][
"token_url"],
39 """Extra data that needs to be appended to the authorize url."""
40 return {
"scope":
"*",
"response_type":
"code"}
43 """Initialize local Geocaching API auth implementation."""
44 redirect_uri = external_data[
"state"][
"redirect_uri"]
46 "grant_type":
"authorization_code",
47 "code": external_data[
"code"],
48 "redirect_uri": redirect_uri,
50 token = await self._token_request(data)
52 token[
"redirect_uri"] = redirect_uri
58 "client_id": self.client_id,
59 "client_secret": self.client_secret,
60 "grant_type":
"refresh_token",
61 "refresh_token": token[
"refresh_token"],
63 "redirect_uri": token[
"redirect_uri"],
66 new_token = await self._token_request(data)
67 return {**token, **new_token}
dict async_resolve_external_data(self, Any external_data)
dict extra_authorize_data(self)
dict _async_refresh_token(self, dict token)
None __init__(self, HomeAssistant hass, str auth_domain, ClientCredential credential)