Lines Matching full:credentials
16 """Interfaces for credentials."""
26 class Credentials(object): class
27 """Base class for all credentials.
29 All credentials have a :attr:`token` that is used for authentication and
33 Most credentials will be :attr:`invalid` until :meth:`refresh` is called.
34 Credentials can do this automatically before the first HTTP request in
37 Although the token and expiration will change as the credentials are
38 :meth:`refreshed <refresh>` and used, credentials should be considered
39 immutable. Various credentials will accept configuration such as private
41 construction. Some classes will provide mechanisms to copy the credentials
57 """Checks if the credentials are expired.
59 Note that credentials can be invalid but not expired because
60 Credentials with :attr:`expiry` set to None is considered to never
73 """Checks the validity of the credentials.
75 This is True if the credentials have a :attr:`token` and the token
94 google.auth.exceptions.RefreshError: If the credentials could
118 Refreshes the credentials if necessary, then calls :meth:`apply` to
137 class CredentialsWithQuotaProject(Credentials):
138 """Abstract base for credentials supporting ``with_quota_project`` factory"""
141 """Returns a copy of these credentials with a modified quota project.
148 google.oauth2.credentials.Credentials: A new credentials instance.
153 class AnonymousCredentials(Credentials):
154 """Credentials that do not provide any authentication information.
157 local service emulators that do not use credentials.
162 """Returns `False`, anonymous credentials never expire."""
167 """Returns `True`, anonymous credentials are always valid."""
171 """Raises :class:`ValueError``, anonymous credentials cannot be
173 raise ValueError("Anonymous credentials cannot be refreshed.")
176 """Anonymous credentials do nothing to the request.
184 raise ValueError("Anonymous credentials don't support tokens.")
187 """Anonymous credentials do nothing to the request."""
192 """Interface for credentials whose scopes can be queried.
194 OAuth 2.0-based credentials allow limiting access using scopes as described
196 If a credential class implements this interface then the credentials either
199 Some credentials require scopes in order to obtain a token. You can check
202 if credentials.requires_scopes:
204 credentials = credentials.with_scopes(scopes=['one', 'two'])
206 Credentials that require scopes must either be constructed with scopes::
208 credentials = SomeScopedCredentials(scopes=['one', 'two'])
212 scoped_credentials = credentials.with_scopes(scopes=['one', 'two'])
214 Some credentials have scopes but do not allow or require scopes to be set,
215 these credentials can be used as-is.
227 """Sequence[str]: the credentials' current set of scopes."""
232 """Sequence[str]: the credentials' current set of default scopes."""
237 """True if these credentials require scopes to obtain an access token.
242 """Checks if the credentials have the given scopes.
245 credentials are :attr:`~Credentials.invalid`.
251 bool: True if the credentials have the given scopes.
260 """Interface for credentials whose scopes can be replaced while copying.
262 OAuth 2.0-based credentials allow limiting access using scopes as described
264 If a credential class implements this interface then the credentials either
267 Some credentials require scopes in order to obtain a token. You can check
270 if credentials.requires_scopes:
272 credentials = credentials.create_scoped(['one', 'two'])
274 Credentials that require scopes must either be constructed with scopes::
276 credentials = SomeScopedCredentials(scopes=['one', 'two'])
280 scoped_credentials = credentials.with_scopes(scopes=['one', 'two'])
282 Some credentials have scopes but do not allow or require scopes to be set,
283 these credentials can be used as-is.
290 """Create a copy of these credentials with the specified scopes.
294 current credentials.
297 NotImplementedError: If the credentials' scopes can not be changed.
304 def with_scopes_if_required(credentials, scopes, default_scopes=None): argument
305 """Creates a copy of the credentials with scopes if scoping is required.
308 specific type of credentials you are using (such as when you use
310 :meth:`Scoped.with_scopes` if the credentials are scoped credentials and if
311 the credentials require scoping. Otherwise, it will return the credentials
315 credentials (google.auth.credentials.Credentials): The credentials to
322 google.auth.credentials.Credentials: Either a new set of scoped
323 credentials, or the passed in credentials instance if no scoping
326 if isinstance(credentials, Scoped) and credentials.requires_scopes:
327 return credentials.with_scopes(scopes, default_scopes=default_scopes)
329 return credentials
334 """Interface for credentials that can cryptographically sign messages."""