Interface IAuthorizationCodeFlow (1.68.0)

public interface IAuthorizationCodeFlow : IDisposable

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

Namespace

Google.Apis.Auth.OAuth2.Flows

Assembly

Google.Apis.Auth.dll

Properties

AccessMethod

IAccessMethod AccessMethod { get; }

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

Property Value
Type Description
IAccessMethod

Clock

IClock Clock { get; }

Gets the clock.

Property Value
Type Description
IClock

DataStore

IDataStore DataStore { get; }

Gets the data store used to store the credentials.

Property Value
Type Description
IDataStore

Methods

CreateAuthorizationCodeRequest(string)

AuthorizationCodeRequestUrl CreateAuthorizationCodeRequest(string redirectUri)

Creates an authorization code request with the specified redirect URI.

Parameter
Name Description
redirectUri string
Returns
Type Description
AuthorizationCodeRequestUrl

DeleteTokenAsync(string, CancellationToken)

Task DeleteTokenAsync(string userId, CancellationToken taskCancellationToken)

Asynchronously deletes the user's token using the flow's IDataStore.

Parameters
Name Description
userId string

User identifier.

taskCancellationToken CancellationToken

Cancellation token to cancel operation.

Returns
Type Description
Task

ExchangeCodeForTokenAsync(string, string, string, CancellationToken)

Task<TokenResponse> ExchangeCodeForTokenAsync(string userId, string code, string redirectUri, CancellationToken taskCancellationToken)

Asynchronously exchanges an authorization code for an access token.

Parameters
Name Description
userId string

User identifier.

code string

Authorization code received from the authorization server.

redirectUri string

Redirect URI which is used in the token request.

taskCancellationToken CancellationToken

Cancellation token to cancel operation.

Returns
Type Description
TaskTokenResponse

Token response which contains the access token.

LoadTokenAsync(string, CancellationToken)

Task<TokenResponse> LoadTokenAsync(string userId, CancellationToken taskCancellationToken)

Asynchronously loads the user's token using the flow's IDataStore.

Parameters
Name Description
userId string

User identifier

taskCancellationToken CancellationToken

Cancellation token to cancel operation

Returns
Type Description
TaskTokenResponse

Token response

RefreshTokenAsync(string, string, CancellationToken)

Task<TokenResponse> RefreshTokenAsync(string userId, string refreshToken, CancellationToken taskCancellationToken)

Asynchronously refreshes an access token using a refresh token.

Parameters
Name Description
userId string

User identifier.

refreshToken string

Refresh token which is used to get a new access token.

taskCancellationToken CancellationToken

Cancellation token to cancel operation.

Returns
Type Description
TaskTokenResponse

Token response which contains the access token and the input refresh token.

RevokeTokenAsync(string, string, CancellationToken)

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.

Parameters
Name Description
userId string

User identifier.

token string

Access token to be revoked.

taskCancellationToken CancellationToken

Cancellation token to cancel operation.

Returns
Type Description
Task

true if the token was revoked successfully.

Remarks

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.

ShouldForceTokenRetrieval()

bool ShouldForceTokenRetrieval()

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

Returns
Type Description
bool

Extension Method