Class AuthorizationCodeWebApp
Thread safe OAuth 2.0 authorization code flow for a web application that persists end-user credentials.
Inherited Members
Namespace: Google.Apis.Auth.OAuth2.Web
Assembly: Google.Apis.Auth.dll
Syntax
public class AuthorizationCodeWebApp
Constructors
AuthorizationCodeWebApp(IAuthorizationCodeFlow, string, string)
Constructs a new authorization code installed application with the given flow and code receiver.
Declaration
public AuthorizationCodeWebApp(IAuthorizationCodeFlow flow, string redirectUri, string state)
Parameters
Type | Name | Description |
---|---|---|
IAuthorization |
flow | |
string | redirectUri | |
string | state |
Fields
StateKey
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.
Declaration
public const string StateKey = "oauth_"
Field Value
Type | Description |
---|---|
string |
StateRandomLength
The length of the random number which will be added to the end of the state parameter.
Declaration
public const int StateRandomLength = 8
Field Value
Type | Description |
---|---|
int |
Properties
Flow
Gets the authorization code flow.
Declaration
public IAuthorizationCodeFlow Flow { get; }
Property Value
Type | Description |
---|---|
IAuthorization |
RedirectUri
Gets the OAuth2 callback redirect URI.
Declaration
public string RedirectUri { get; }
Property Value
Type | Description |
---|---|
string |
State
Gets the state which is used to navigate back to the page that started the OAuth flow.
Declaration
public string State { get; }
Property Value
Type | Description |
---|---|
string |
Methods
AuthorizeAsync(string, CancellationToken)
Asynchronously authorizes the web application to access user's protected data.
Declaration
public Task<AuthorizationCodeWebApp.AuthResult> AuthorizeAsync(string userId, CancellationToken taskCancellationToken)
Parameters
Type | Name | Description |
---|---|---|
string | userId | User identifier |
Cancellation |
taskCancellationToken | Cancellation token to cancel an operation |
Returns
Type | Description |
---|---|
Task<Authorization |
Auth result object which contains the user's credential or redirect URI for the authorization server |
ShouldRequestAuthorizationCode(TokenResponse)
Determines the need for retrieval of a new authorization code, based on the given token and the authorization code flow.
Declaration
public bool ShouldRequestAuthorizationCode(TokenResponse token)
Parameters
Type | Name | Description |
---|---|---|
Token |
token |
Returns
Type | Description |
---|---|
bool |