A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://google-auth.readthedocs.io/en/stable/reference/google.oauth2.credentials.html below:

google.oauth2.credentials module — google-auth 1.30.0 documentation

google.oauth2.credentials module¶

OAuth 2.0 Credentials.

This module provides credentials based on OAuth 2.0 access and refresh tokens. These credentials usually access resources on behalf of a user (resource owner).

Specifically, this is intended to use access tokens acquired using the Authorization Code grant and can refresh those tokens using a optional refresh token.

Obtaining the initial access and refresh token is outside of the scope of this module. Consult rfc6749 section 4.1 for complete details on the Authorization Code grant flow.

class Credentials(token, refresh_token=None, id_token=None, token_uri=None, client_id=None, client_secret=None, scopes=None, default_scopes=None, quota_project_id=None, expiry=None, rapt_token=None)[source]¶

Bases: google.auth.credentials.ReadOnlyScoped, google.auth.credentials.CredentialsWithQuotaProject

Credentials using OAuth 2.0 access and refresh tokens.

The credentials are considered immutable. If you want to modify the quota project, use with_quota_project() or

credentials = credentials.with_quota_project('myproject-123)

If reauth is enabled, pyu2f dependency has to be installed in order to use security key reauth feature. Dependency can be installed via pip install pyu2f or pip install google-auth[reauth].

Parameters:
refresh_token¶

The OAuth 2.0 refresh token.

scopes¶

The OAuth 2.0 permission scopes.

token_uri¶

The OAuth 2.0 authorization server’s token endpoint URI.

id_token¶

The Open ID Connect ID Token.

Depending on the authorization server and the scopes requested, this may be populated when credentials are obtained and updated when refresh() is called. This token is a JWT. It can be verified and decoded using google.oauth2.id_token.verify_oauth2_token().

client_id¶

The OAuth 2.0 client ID.

client_secret¶

The OAuth 2.0 client secret.

requires_scopes¶

OAuth 2.0 credentials have their scopes set when the initial token is requested and can not be changed.

rapt_token¶

The reauth Proof Token.

with_quota_project(quota_project_id)[source]¶

Returns a copy of these credentials with a modified quota project.

refresh(request)[source]¶

Refreshes the access token.

Creates a Credentials instance from parsed authorized user info.

classmethod from_authorized_user_file(filename, scopes=None)[source]¶

Creates a Credentials instance from an authorized user json file.

Parameters:
  • filename (str) – The path to the authorized user json file.
  • scopes (Sequence [ str ]) – Optional list of scopes to include in the credentials.
Returns:
The constructed

credentials.

Return type:

google.oauth2.credentials.Credentials

Raises:

ValueError – If the file is not in the expected format.

to_json(strip=None)[source]¶

Utility function that creates a JSON representation of a Credentials object.

Parameters: strip (Sequence [ str ]) – Optional list of members to exclude from the generated JSON. Returns: A JSON representation of this instance. When converted into a dictionary, it can be passed to from_authorized_user_info() to create a new credential instance. Return type: str
apply(headers, token=None)[source]¶

Apply the token to the authentication header.

Parameters:
  • headers (Mapping) – The HTTP request headers.
  • token (Optional [ str ]) – If specified, overrides the current access token.
before_request(request, method, url, headers)[source]¶

Performs credential-specific before request logic.

Refreshes the credentials if necessary, then calls apply() to apply the token to the authentication header.

Parameters:
  • request (google.auth.transport.Request) – The object used to make HTTP requests.
  • method (str) – The request’s HTTP method or the RPC method being invoked.
  • url (str) – The request’s URI or the RPC service’s URI.
  • headers (Mapping) – The request’s headers.
default_scopes¶

the credentials’ current set of default scopes.

expired¶

Checks if the credentials are expired.

Note that credentials can be invalid but not expired because Credentials with expiry set to None is considered to never expire.

has_scopes(scopes)¶

Checks if the credentials have the given scopes.

Parameters: scopes (Sequence [ str ]) – The list of scopes to check. Returns: True if the credentials have the given scopes. Return type: bool
quota_project_id¶

Project to use for quota and billing purposes.

valid¶

Checks the validity of the credentials.

This is True if the credentials have a token and the token is not expired.

class UserAccessTokenCredentials(account=None, quota_project_id=None)[source]¶

Bases: google.auth.credentials.CredentialsWithQuotaProject

Access token credentials for user account.

Obtain the access token for a given user account or the current active user account with the gcloud auth print-access-token command.

Parameters:
with_account(account)[source]¶

Create a new instance with the given account.

with_quota_project(quota_project_id)[source]¶

Returns a copy of these credentials with a modified quota project.

refresh(request)[source]¶

Refreshes the access token.

before_request(request, method, url, headers)[source]¶

Performs credential-specific before request logic.

Refreshes the credentials if necessary, then calls apply() to apply the token to the authentication header.

Parameters:
  • request (google.auth.transport.Request) – The object used to make HTTP requests.
  • method (str) – The request’s HTTP method or the RPC method being invoked.
  • url (str) – The request’s URI or the RPC service’s URI.
  • headers (Mapping) – The request’s headers.
apply(headers, token=None)¶

Apply the token to the authentication header.

Parameters:
  • headers (Mapping) – The HTTP request headers.
  • token (Optional [ str ]) – If specified, overrides the current access token.
expired¶

Checks if the credentials are expired.

Note that credentials can be invalid but not expired because Credentials with expiry set to None is considered to never expire.

quota_project_id¶

Project to use for quota and billing purposes.

valid¶

Checks the validity of the credentials.

This is True if the credentials have a token and the token is not expired.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4