adafruit_oauth2
¶
CircuitPython helper for OAuth2.0 authorization to access Google APIs.
Author(s): Brent Rubell
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- class adafruit_oauth2.OAuth2(requests, client_id, client_secret, scopes, access_token=None, refresh_token=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 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()¶
Refreshes an expired access token. :return: True if able to refresh an access token, False otherwise.
- request_codes()¶
Identifies your application and access scopes with Google’s authorization server. Attempts to request device and user codes
- wait_for_authorization()¶
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.