Class AuthorizationCodeWebApp (1.60.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

GoogleApisAuthOAuth2Web

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
NameDescription
flowIAuthorizationCodeFlow
redirectUristring
statestring

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
TypeDescription
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
TypeDescription
int

Properties

Flow

public IAuthorizationCodeFlow Flow { get; }

Gets the authorization code flow.

Property Value
TypeDescription
IAuthorizationCodeFlow

RedirectUri

public string RedirectUri { get; }

Gets the OAuth2 callback redirect URI.

Property Value
TypeDescription
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
TypeDescription
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
NameDescription
userIdstring

User identifier

taskCancellationTokenCancellationToken

Cancellation token to cancel an operation

Returns
TypeDescription
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
NameDescription
tokenTokenResponse
Returns
TypeDescription
bool

Extension Method