Class GoogleWebAuthorizationBroker
A helper utility to manage the authorization code flow.
Inheritance
Inherited Members
Namespace: Google.Apis.Auth.OAuth2
Assembly: Google.Apis.Auth.dll
Syntax
public class GoogleWebAuthorizationBroker
Remarks
This class is only suitable for client-side use, as it starts a local browser that requires user interaction. Do not use this class when executing on a web server, or any cases where the authenticating end-user is not able to do directly interact with a launched browser.
Fields
Folder
The folder which is used by the FileDataStore.
Declaration
public static string Folder
Field Value
Type | Description |
---|---|
System.String |
Remarks
The reason that this is not 'private const' is that a user can change it and store the credentials in a different location.
Methods
AuthorizeAsync(ClientSecrets, IEnumerable<String>, String, CancellationToken, IDataStore, ICodeReceiver)
Asynchronously authorizes the specified user. Requires user interaction; see GoogleWebAuthorizationBroker remarks for more details.
Declaration
public static Task<UserCredential> AuthorizeAsync(ClientSecrets clientSecrets, IEnumerable<string> scopes, string user, CancellationToken taskCancellationToken, IDataStore dataStore = null, ICodeReceiver codeReceiver = null)
Parameters
Type | Name | Description |
---|---|---|
ClientSecrets | clientSecrets | The client secrets. |
System.Collections.Generic.IEnumerable<System.String> | scopes | The scopes which indicate the Google API access your application is requesting. |
System.String | user | The user to authorize. |
System.Threading.CancellationToken | taskCancellationToken | Cancellation token to cancel an operation. |
Google.Apis.Util.Store.IDataStore | dataStore | The data store, if not specified a file data store will be used. |
ICodeReceiver | codeReceiver | The code receiver, if not specified a local server code receiver will be used. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<UserCredential> | User credential. |
Remarks
In case no data store is specified, FileDataStore will be used by default.
AuthorizeAsync(GoogleAuthorizationCodeFlow.Initializer, IEnumerable<String>, String, CancellationToken, IDataStore, ICodeReceiver)
The core logic for asynchronously authorizing the specified user. Requires user interaction; see GoogleWebAuthorizationBroker remarks for more details.
Declaration
public static Task<UserCredential> AuthorizeAsync(GoogleAuthorizationCodeFlow.Initializer initializer, IEnumerable<string> scopes, string user, CancellationToken taskCancellationToken, IDataStore dataStore = null, ICodeReceiver codeReceiver = null)
Parameters
Type | Name | Description |
---|---|---|
GoogleAuthorizationCodeFlow.Initializer | initializer | The authorization code initializer. |
System.Collections.Generic.IEnumerable<System.String> | scopes | The scopes which indicate the Google API access your application is requesting. |
System.String | user | The user to authorize. |
System.Threading.CancellationToken | taskCancellationToken | Cancellation token to cancel an operation. |
Google.Apis.Util.Store.IDataStore | dataStore | The data store, if not specified a file data store will be used. |
ICodeReceiver | codeReceiver | The code receiver, if not specified a local server code receiver will be used. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<UserCredential> | User credential. |
AuthorizeAsync(Stream, IEnumerable<String>, String, CancellationToken, IDataStore, ICodeReceiver)
Asynchronously authorizes the specified user. Requires user interaction; see GoogleWebAuthorizationBroker remarks for more details.
Declaration
public static Task<UserCredential> AuthorizeAsync(Stream clientSecretsStream, IEnumerable<string> scopes, string user, CancellationToken taskCancellationToken, IDataStore dataStore = null, ICodeReceiver codeReceiver = null)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | clientSecretsStream | The client secrets stream. The authorization code flow constructor is responsible for disposing the stream. |
System.Collections.Generic.IEnumerable<System.String> | scopes | The scopes which indicate the Google API access your application is requesting. |
System.String | user | The user to authorize. |
System.Threading.CancellationToken | taskCancellationToken | Cancellation token to cancel an operation. |
Google.Apis.Util.Store.IDataStore | dataStore | The data store, if not specified a file data store will be used. |
ICodeReceiver | codeReceiver | The code receiver, if not specified a local server code receiver will be used. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<UserCredential> | User credential. |
Remarks
In case no data store is specified, FileDataStore will be used by default.
ReauthorizeAsync(UserCredential, CancellationToken, ICodeReceiver)
Asynchronously reauthorizes the user. This method should be called if the users want to authorize after they revoked the token. Requires user interaction; see GoogleWebAuthorizationBroker remarks for more details.
Declaration
public static Task ReauthorizeAsync(UserCredential userCredential, CancellationToken taskCancellationToken, ICodeReceiver codeReceiver = null)
Parameters
Type | Name | Description |
---|---|---|
UserCredential | userCredential | The current user credential. Its Token will be updated. |
System.Threading.CancellationToken | taskCancellationToken | Cancellation token to cancel an operation. |
ICodeReceiver | codeReceiver | The code receiver, if not specified a local server code receiver will be used. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |