Google API Client Library for .NET  1.10.0
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Google.Apis.Auth.OAuth2.ComputeCredential Class Reference

Google OAuth 2.0 credential for accessing protected resources using an access token. The Google OAuth 2.0 Authorization Server supports server-to-server interactions such as those between a web application and Google Cloud Storage. The requesting application has to prove its own identity to gain access to an API, and an end-user doesn't have to be involved. More...

Inheritance diagram for Google.Apis.Auth.OAuth2.ComputeCredential:
Google.Apis.Auth.OAuth2.ServiceCredential Google.Apis.Auth.OAuth2.ICredential Google.Apis.Http.IHttpExecuteInterceptor Google.Apis.Http.IHttpUnsuccessfulResponseHandler Google.Apis.Http.IConfigurableHttpClientInitializer Google.Apis.Auth.OAuth2.ITokenAccess

Classes

class  Initializer
 An initializer class for the Compute credential. It uses GoogleAuthConsts.ComputeTokenUrl as the token server URL. More...
 

Public Member Functions

 ComputeCredential ()
 Constructs a new Compute credential instance. More...
 
 ComputeCredential (Initializer initializer)
 Constructs a new Compute credential instance. More...
 
override async Task< bool > RequestAccessTokenAsync (CancellationToken taskCancellationToken)
 Requests a new token. More...
 
- Public Member Functions inherited from Google.Apis.Auth.OAuth2.ServiceCredential
 ServiceCredential (Initializer initializer)
 Constructs a new service account credential using the given initializer. More...
 
void Initialize (ConfigurableHttpClient httpClient)
 Initializes a HTTP client after it was created. More...
 
async Task InterceptAsync (HttpRequestMessage request, CancellationToken cancellationToken)
 
async Task< bool > HandleResponseAsync (HandleUnsuccessfulResponseArgs args)
 Handles an abnormal response when sending a HTTP request. A simple rule must be followed, if you modify the request object in a way that the abnormal response can be resolved, you must return true. More...
 
virtual async Task< string > GetAccessTokenForRequestAsync (string authUri=null, CancellationToken cancellationToken=default(CancellationToken))
 Gets an access token to authorize a request. If the existing token has expired, try to refresh it first.

See Also
ITokenAccess.GetAccessTokenForRequestAsync
More...
 

Static Public Member Functions

static Task< bool > IsRunningOnComputeEngine ()
 Detects if application is running on Google Compute Engine. This is achieved by attempting to contact GCE metadata server, that is only available on GCE. The check is only performed the first time you call this method, subsequent invocations used cached result of the first call. More...
 

Public Attributes

const string MetadataServerUrl = "http://metadata.google.internal"
 The metadata server url. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from Google.Apis.Auth.OAuth2.ServiceCredential
static readonly ILogger Logger = ApplicationContext.Logger.ForType<ServiceCredential>()
 
- Properties inherited from Google.Apis.Auth.OAuth2.ServiceCredential
string TokenServerUrl [get]
 Gets the token server URL. More...
 
IClock Clock [get]
 Gets the clock used to refresh the token if it expires. More...
 
IAccessMethod AccessMethod [get]
 Gets the method for presenting the access token to the resource server. More...
 
ConfigurableHttpClient HttpClient [get]
 Gets the HTTP client used to make authentication requests to the server. More...
 
TokenResponse Token [get, set]
 Gets the token response which contains the access token. More...
 

Detailed Description

Google OAuth 2.0 credential for accessing protected resources using an access token. The Google OAuth 2.0 Authorization Server supports server-to-server interactions such as those between a web application and Google Cloud Storage. The requesting application has to prove its own identity to gain access to an API, and an end-user doesn't have to be involved.

More details about Compute Engine authentication is available at: https://cloud.google.com/compute/docs/authentication.

Constructor & Destructor Documentation

Google.Apis.Auth.OAuth2.ComputeCredential.ComputeCredential ( )
inline

Constructs a new Compute credential instance.

Google.Apis.Auth.OAuth2.ComputeCredential.ComputeCredential ( Initializer  initializer)
inline

Constructs a new Compute credential instance.

Member Function Documentation

static Task<bool> Google.Apis.Auth.OAuth2.ComputeCredential.IsRunningOnComputeEngine ( )
inlinestatic

Detects if application is running on Google Compute Engine. This is achieved by attempting to contact GCE metadata server, that is only available on GCE. The check is only performed the first time you call this method, subsequent invocations used cached result of the first call.

override async Task<bool> Google.Apis.Auth.OAuth2.ComputeCredential.RequestAccessTokenAsync ( CancellationToken  taskCancellationToken)
inlinevirtual

Requests a new token.

Parameters
taskCancellationTokenCancellation token to cancel operation.
Returns
true if a new token was received successfully.

Implements Google.Apis.Auth.OAuth2.ServiceCredential.

Member Data Documentation

const string Google.Apis.Auth.OAuth2.ComputeCredential.MetadataServerUrl = "http://metadata.google.internal"

The metadata server url.


The documentation for this class was generated from the following file: