Google API Client Library for .NET  1.10.0
Classes | Public Member Functions | Properties | List of all members
Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow Class Reference

Thread-safe OAuth 2.0 authorization code flow that manages and persists end-user credentials. More...

Inheritance diagram for Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow:
Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow

Classes

class  Initializer
 An initializer class for the authorization code flow. More...
 

Public Member Functions

 AuthorizationCodeFlow (Initializer initializer)
 Constructs a new flow using the initializer's properties. More...
 
async Task< TokenResponseLoadTokenAsync (string userId, CancellationToken taskCancellationToken)
 Asynchronously loads the user's token using the flow's Google.Apis.Util.Store.IDataStore. More...
 
async Task DeleteTokenAsync (string userId, CancellationToken taskCancellationToken)
 Asynchronously deletes the user's token using the flow's Google.Apis.Util.Store.IDataStore. More...
 
virtual AuthorizationCodeRequestUrl CreateAuthorizationCodeRequest (string redirectUri)
 Creates an authorization code request with the specified redirect URI. More...
 
async Task< TokenResponseExchangeCodeForTokenAsync (string userId, string code, string redirectUri, CancellationToken taskCancellationToken)
 Asynchronously exchanges code with a token. More...
 
async Task< TokenResponseRefreshTokenAsync (string userId, string refreshToken, CancellationToken taskCancellationToken)
 Asynchronously refreshes an access token using a refresh token. More...
 
virtual Task RevokeTokenAsync (string userId, string token, CancellationToken taskCancellationToken)
 Asynchronously revokes the specified token. This method disconnects the user's account from the OAuth 2.0 application. It should be called upon removing the user account from the site. More...
 
virtual bool ShouldForceTokenRetrieval ()
 Indicates if a new token needs to be retrieved and stored regardless of normal circumstances. More...
 
async Task< TokenResponseFetchTokenAsync (string userId, TokenRequest request, CancellationToken taskCancellationToken)
 Retrieve a new token from the server using the specified request. More...
 
void Dispose ()
 

Properties

string TokenServerUrl [get]
 Gets the token server URL. More...
 
string AuthorizationServerUrl [get]
 Gets the authorization code server URL. More...
 
ClientSecrets ClientSecrets [get]
 Gets the client secrets which includes the client identifier and its secret. More...
 
IDataStore DataStore [get]
 Gets the data store used to store the credentials. More...
 
IEnumerable< string > Scopes [get]
 Gets the scopes which indicate the API access your application is requesting. More...
 
ConfigurableHttpClient HttpClient [get]
 Gets the HTTP client used to make authentication requests to the server. More...
 
IAccessMethod AccessMethod [get]
 
IClock Clock [get]
 
- Properties inherited from Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow
IAccessMethod AccessMethod [get]
 Gets the method for presenting the access token to the resource server. More...
 
IClock Clock [get]
 Gets the clock. More...
 
IDataStore DataStore [get]
 Gets the data store used to store the credentials. More...
 

Detailed Description

Thread-safe OAuth 2.0 authorization code flow that manages and persists end-user credentials.

This is designed to simplify the flow in which an end-user authorizes the application to access their protected data, and then the application has access to their data based on an access token and a refresh token to refresh that access token when it expires.

Constructor & Destructor Documentation

Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.AuthorizationCodeFlow ( Initializer  initializer)
inline

Constructs a new flow using the initializer's properties.

Member Function Documentation

virtual AuthorizationCodeRequestUrl Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.CreateAuthorizationCodeRequest ( string  redirectUri)
inlinevirtual

Creates an authorization code request with the specified redirect URI.

Implements Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.

Reimplemented in Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.

async Task Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.DeleteTokenAsync ( string  userId,
CancellationToken  taskCancellationToken 
)
inline

Asynchronously deletes the user's token using the flow's Google.Apis.Util.Store.IDataStore.

Parameters
userIdUser identifier.
taskCancellationTokenCancellation token to cancel operation.

Implements Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.

async Task<TokenResponse> Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.ExchangeCodeForTokenAsync ( string  userId,
string  code,
string  redirectUri,
CancellationToken  taskCancellationToken 
)
inline

Asynchronously exchanges code with a token.

Parameters
userIdUser identifier.
codeAuthorization code received from the authorization server.
redirectUriRedirect URI which is used in the token request.
taskCancellationTokenCancellation token to cancel operation.
Returns
Token response which contains the access token.

Implements Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.

async Task<TokenResponse> Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.FetchTokenAsync ( string  userId,
TokenRequest  request,
CancellationToken  taskCancellationToken 
)
inline

Retrieve a new token from the server using the specified request.

Parameters
userIdUser identifier.
requestToken request.
taskCancellationTokenCancellation token to cancel operation.
Returns
Token response with the new access token.
async Task<TokenResponse> Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.LoadTokenAsync ( string  userId,
CancellationToken  taskCancellationToken 
)
inline

Asynchronously loads the user's token using the flow's Google.Apis.Util.Store.IDataStore.

Parameters
userIdUser identifier
taskCancellationTokenCancellation token to cancel operation
Returns
Token response

Implements Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.

async Task<TokenResponse> Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.RefreshTokenAsync ( string  userId,
string  refreshToken,
CancellationToken  taskCancellationToken 
)
inline

Asynchronously refreshes an access token using a refresh token.

Parameters
userIdUser identifier.
refreshTokenRefresh token which is used to get a new access token.
taskCancellationTokenCancellation token to cancel operation.
Returns
Token response which contains the access token and the input refresh token.

Implements Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.

virtual Task Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.RevokeTokenAsync ( string  userId,
string  token,
CancellationToken  taskCancellationToken 
)
inlinevirtual

Asynchronously revokes the specified token. This method disconnects the user's account from the OAuth 2.0 application. It should be called upon removing the user account from the site.

If revoking the token succeeds, the user's credential is removed from the data store and the user MUST authorize the application again before the application can access the user's private resources.

Parameters
userIdUser identifier.
tokenAccess token to be revoked.
taskCancellationTokenCancellation token to cancel operation.
Returns
true if the token was revoked successfully.

Implements Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.

Reimplemented in Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.

virtual bool Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.ShouldForceTokenRetrieval ( )
inlinevirtual

Indicates if a new token needs to be retrieved and stored regardless of normal circumstances.

Implements Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.

Reimplemented in Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.

Property Documentation

string Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.AuthorizationServerUrl
get

Gets the authorization code server URL.

ClientSecrets Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.ClientSecrets
get

Gets the client secrets which includes the client identifier and its secret.

IDataStore Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.DataStore
get

Gets the data store used to store the credentials.

ConfigurableHttpClient Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.HttpClient
get

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

IEnumerable<string> Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.Scopes
get

Gets the scopes which indicate the API access your application is requesting.

string Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.TokenServerUrl
get

Gets the token server URL.


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