public class AuthorizationCodeWebApp
Thread safe OAuth 2.0 authorization code flow for a web application that persists end-user credentials.
Namespace
Google.Apis.Auth.OAuth2.WebAssembly
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 |
Int32 |
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 async 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 |
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 | |
---|---|
Name | Description |
token | TokenResponse |
Returns | |
---|---|
Type | Description |
Boolean |