Class AuthorizationCodeWebApp (1.68.0)

public class AuthorizationCodeWebApp

Thread safe OAuth 2.0 authorization code flow for a web application that persists end-user credentials.

Inheritance

object > AuthorizationCodeWebApp

Namespace

Google.Apis.Auth.OAuth2.Web

Assembly

Google.Apis.Auth.dll

Constructors

AuthorizationCodeWebApp(IAuthorizationCodeFlow, string, string)

public AuthorizationCodeWebApp(IAuthorizationCodeFlow flow, string redirectUri, string state)

Constructs a new authorization code installed application with the given flow and code receiver.

Parameters
Name Description
flow IAuthorizationCodeFlow
redirectUri string
state string

Fields

StateKey

public const string StateKey = "oauth_"

The state key. As part of making the request for authorization code we save the original request to verify that this server create the original request.

Field Value
Type Description
string

StateRandomLength

public const int StateRandomLength = 8

The length of the random number which will be added to the end of the state parameter.

Field Value
Type Description
int

Properties

Flow

public IAuthorizationCodeFlow Flow { get; }

Gets the authorization code flow.

Property Value
Type Description
IAuthorizationCodeFlow

RedirectUri

public string RedirectUri { get; }

Gets the OAuth2 callback redirect URI.

Property Value
Type Description
string

State

public string State { get; }

Gets the state which is used to navigate back to the page that started the OAuth flow.

Property Value
Type Description
string

Methods

AuthorizeAsync(string, CancellationToken)

public Task<AuthorizationCodeWebApp.AuthResult> AuthorizeAsync(string userId, CancellationToken taskCancellationToken)

Asynchronously authorizes the web application to access user's protected data.

Parameters
Name Description
userId string

User identifier

taskCancellationToken CancellationToken

Cancellation token to cancel an operation

Returns
Type Description
TaskAuthorizationCodeWebAppAuthResult

Auth result object which contains the user's credential or redirect URI for the authorization server

ShouldRequestAuthorizationCode(TokenResponse)

public bool ShouldRequestAuthorizationCode(TokenResponse token)

Determines the need for retrieval of a new authorization code, based on the given token and the authorization code flow.

Parameter
Name Description
token TokenResponse
Returns
Type Description
bool

Extension Method