adafruit_oauth2

CircuitPython helper for OAuth2.0 authorization to access Google APIs.

  • Author(s): Brent Rubell

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_oauth2.OAuth2(requests: Session, client_id: str, client_secret: str, scopes: List[str], access_token: str | None = None, refresh_token: str | None = None)

Implements OAuth2.0 authorization to access Google APIs via the OAuth 2.0 limited-input device application flow. https://developers.google.com/identity/protocols/oauth2/limited-input-device :param adafruit_requests.Session requests: An adafruit_requests object. :param str client_id: The client ID for your application. :param str client_secret: The client secret obtained from the API Console. :param list scopes: Scopes that identify the resources used by the application. :param str access_token: Optional token which authorizes a Google API request. :param str refresh_token: Optional token which allows you to obtain a new access token.

refresh_access_token() bool

Refreshes an expired access token. :return: True if able to refresh an access token, False otherwise.

request_codes() None

Identifies your application and access scopes with Google’s authorization server. Attempts to request device and user codes

wait_for_authorization() bool

Blocking method which polls Google’s authorization server until a response from Google’s authorization server indicating that the user has responded to the access request, or until the user_code has expired. :return: True if successfully authenticated, False otherwise.