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

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 async 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
Task<AuthorizationCodeWebApp.AuthResult>

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
Boolean

Extension Method