Google API Client Library for .NET  1.10.0
Classes | Public Member Functions | Static Protected Attributes | Properties | List of all members
Google.Apis.Auth.OAuth2.ServiceCredential Class Referenceabstract

This type of Google OAuth 2.0 credential enables access to protected resources using an access token when interacting server to server. For example, a service account credential could be used to access Google Cloud Storage from a web application without a user's involvement. More...

Inheritance diagram for 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 Google.Apis.Auth.OAuth2.ComputeCredential Google.Apis.Auth.OAuth2.ServiceAccountCredential

Classes

class  Initializer
 An initializer class for the service credential. More...
 

Public Member Functions

 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...
 
abstract Task< bool > RequestAccessTokenAsync (CancellationToken taskCancellationToken)
 Requests a new token. More...
 

Static Protected Attributes

static readonly ILogger Logger = ApplicationContext.Logger.ForType<ServiceCredential>()
 

Properties

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

This type of Google OAuth 2.0 credential enables access to protected resources using an access token when interacting server to server. For example, a service account credential could be used to access Google Cloud Storage from a web application without a user's involvement.

ServiceAccountCredential inherits from this class in order to support Service Account. More details available at: https://developers.google.com/accounts/docs/OAuth2ServiceAccount. Google.Apis.Auth.OAuth2.ComputeCredential is another example for a class that inherits from this class in order to support Compute credentials. For more information about Compute authentication, see: https://cloud.google.com/compute/docs/authentication.

Constructor & Destructor Documentation

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

Constructs a new service account credential using the given initializer.

Member Function Documentation

virtual async Task<string> Google.Apis.Auth.OAuth2.ServiceCredential.GetAccessTokenForRequestAsync ( string  authUri = null,
CancellationToken  cancellationToken = default(CancellationToken) 
)
inlinevirtual

Gets an access token to authorize a request. If the existing token has expired, try to refresh it first.

See Also
ITokenAccess.GetAccessTokenForRequestAsync

Implements Google.Apis.Auth.OAuth2.ITokenAccess.

Reimplemented in Google.Apis.Auth.OAuth2.ServiceAccountCredential.

async Task<bool> Google.Apis.Auth.OAuth2.ServiceCredential.HandleResponseAsync ( HandleUnsuccessfulResponseArgs  args)
inline

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.

Parameters
argsHandle response argument which contains properties such as the request, response, current failed try.
Returns
Whether this handler has made a change that requires the request to be resent.

Implements Google.Apis.Http.IHttpUnsuccessfulResponseHandler.

void Google.Apis.Auth.OAuth2.ServiceCredential.Initialize ( ConfigurableHttpClient  httpClient)
inline

Initializes a HTTP client after it was created.

Implements Google.Apis.Http.IConfigurableHttpClientInitializer.

async Task Google.Apis.Auth.OAuth2.ServiceCredential.InterceptAsync ( HttpRequestMessage  request,
CancellationToken  cancellationToken 
)
inline

Invoked before the request is being sent.

Parameters
requestThe HTTP request message.
cancellationTokenCancellation token to cancel the operation.

Implements Google.Apis.Http.IHttpExecuteInterceptor.

abstract Task<bool> Google.Apis.Auth.OAuth2.ServiceCredential.RequestAccessTokenAsync ( CancellationToken  taskCancellationToken)
pure virtual

Requests a new token.

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

Implemented in Google.Apis.Auth.OAuth2.ServiceAccountCredential, and Google.Apis.Auth.OAuth2.ComputeCredential.

Property Documentation

IAccessMethod Google.Apis.Auth.OAuth2.ServiceCredential.AccessMethod
get

Gets the method for presenting the access token to the resource server.

IClock Google.Apis.Auth.OAuth2.ServiceCredential.Clock
get

Gets the clock used to refresh the token if it expires.

ConfigurableHttpClient Google.Apis.Auth.OAuth2.ServiceCredential.HttpClient
get

Gets the HTTP client used to make authentication requests to the server.

TokenResponse Google.Apis.Auth.OAuth2.ServiceCredential.Token
getset

Gets the token response which contains the access token.

string Google.Apis.Auth.OAuth2.ServiceCredential.TokenServerUrl
get

Gets the token server URL.


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