1 """application_credentials platform for Withings."""
5 from aiowithings
import AUTHORIZATION_URL, TOKEN_URL
15 from .const
import DOMAIN
19 hass: HomeAssistant, auth_domain: str, credential: ClientCredential
20 ) -> config_entry_oauth2_flow.AbstractOAuth2Implementation:
21 """Return auth implementation."""
27 authorize_url=AUTHORIZATION_URL,
34 """Oauth2 implementation that only uses the external url."""
37 """Make a token request and adapt Withings API reply."""
52 if body := new_token.pop(
"body",
None):
53 new_token.update(body)
56 async
def async_resolve_external_data(self, external_data: Any) -> dict:
57 """Resolve the authorization code to tokens."""
60 "action":
"requesttoken",
61 "grant_type":
"authorization_code",
62 "code": external_data[
"code"],
63 "redirect_uri": external_data[
"state"][
"redirect_uri"],
67 async
def _async_refresh_token(self, token: dict) -> dict:
71 "action":
"requesttoken",
72 "grant_type":
"refresh_token",
73 "client_id": self.client_id,
74 "refresh_token": token[
"refresh_token"],
77 return {**token, **new_token}
dict _token_request(self, dict data)
config_entry_oauth2_flow.AbstractOAuth2Implementation async_get_auth_implementation(HomeAssistant hass, str auth_domain, ClientCredential credential)