Ads API .NET library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl Class Reference

Default implementation of OAuth2 provider. More...

Inheritance diagram for Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl:
Google.Api.Ads.Common.Lib.AdsOAuthProviderForServiceAccounts Google.Api.Ads.Common.Lib.AdsOAuthProviderForApplications Google.Api.Ads.Common.Lib.AdsOAuthProvider Google.Api.Ads.Common.Lib.AdsOAuthProvider Google.Api.Ads.Common.Lib.Configurable Google.Api.Ads.Common.Lib.Configurable Google.Api.Ads.Common.Lib.OAuth2ProviderBase Google.Api.Ads.Common.Lib.OAuth2ProviderForApplications Google.Api.Ads.Common.Lib.OAuth2ProviderForServiceAccounts

Public Member Functions

 AdsOAuthProviderImpl (AppConfig config)
 Initializes a new instance of the AdsOAuthProvider class. More...
 
string GetAuthorizationUrl ()
 Gets the authorization URL. More...
 
bool FetchAccessAndRefreshTokens (string authorizationCode)
 Fetches the access and optionally the refresh token if applicable. More...
 
void RevokeRefreshToken ()
 Revokes the refresh token if offline mode is used. More...
 
void RefreshAccessToken ()
 Refreshes the access token if expiring. More...
 
void RefreshAccessTokenInOfflineMode ()
 Refreshes the access token if offline mode is used. More...
 
void GenerateAccessTokenForServiceAccount ()
 Generates the access token for service account. More...
 
void RefreshAccessTokenIfExpiring ()
 Refreshes the access token if expiring. More...
 
virtual string GetAuthHeader ()
 Gets the OAuth authorization header to be used with HTTP requests. More...
 

Protected Member Functions

virtual string CreateAuthorizationUrl ()
 Creates the authorization URL. More...
 
virtual TokenResponse ExchangeCodeForToken (string code)
 Exchanges the authorization code for access and refresh tokens. More...
 
virtual TokenResponse GetAccessTokenForAuthorizationCodeFlow ()
 Refreshes the access token in authorization code flow. More...
 
virtual TokenResponse GetAccessTokenForServiceAccount ()
 Gets the access token in service account flow. More...
 
virtual void RevokeRefreshToken (string refreshToken)
 Revokes the refresh token asynchronously. More...
 

Protected Attributes

readonly AdsFeatureUsageRegistry featureUsageRegistry
 The registry for saving feature usage information.. More...
 

Properties

IHttpClientFactory HttpClientFactory [get, set]
 The HttpClientFactory used for requesting access tokens. More...
 
IClock Clock [get, set]
 The clock used for requesting access tokens. More...
 
AppConfig Config = SystemClock.Default [get]
 Gets the application configuration class for this object. More...
 
string ClientId [get, set]
 Gets or sets the client that is making the request. This value is obtained from the Google Cloud Console during application registration. More...
 
string ClientSecret [get, set]
 Gets or sets the client secret obtained from the Google Cloud Console during application registration. More...
 
string Scope [get, set]
 Gets or sets the API access your application is requesting. This is space delimited. More...
 
string State [get, set]
 Gets or sets a parameter that your application can use for keeping state. The OAuth authorization server roundtrips this parameter. More...
 
string TokenType [get]
 Gets the type of token returned by the server. This field will always have the value Bearer for now. More...
 
string AccessToken [get, set]
 Gets or sets the token that can be sent to a Google API for authentication. More...
 
DateTime UpdatedOn [get, set]
 Gets or sets the time at which access token was retrieved. More...
 
int ExpiresIn [get, set]
 Gets the remaining lifetime on the access token. More...
 
OAuthTokensObtainedCallback OnOAuthTokensObtained [get, set]
 Callback triggered when this provider obtains a new access token or refresh token from the OAuth server. More...
 
bool IsOffline [get, set]
 Indicates if your application needs to access APIs when the user is not present at the browser. This is defaulted to true. More...
 
string RedirectUri = true [get, set]
 Gets or sets where the url where the response is sent. This should be a registered redirect uri on the Google Cloud Console. More...
 
string RefreshToken [get, set]
 Gets or sets a token that may be used to obtain a new access token. Refresh tokens are valid until the user revokes access. More...
 
string ServiceAccountEmail [get]
 Gets the service account email for which access token should be retrieved. More...
 
string PrnEmail [get, set]
 Gets or sets the email of the account for which the call is being made. More...
 
string JwtPrivateKey [get]
 Gets or sets the JWT private key. More...
 
- Properties inherited from Google.Api.Ads.Common.Lib.AdsOAuthProviderForServiceAccounts
string ServiceAccountEmail [get]
 Gets the service account email for which access token should be retrieved. More...
 
string PrnEmail [get, set]
 Gets or sets the email of the account for which the call is being made. More...
 
- Properties inherited from Google.Api.Ads.Common.Lib.AdsOAuthProvider
string ClientId [get, set]
 Gets or sets the client that is making the request. This value is obtained from the API console during application registration. More...
 
string ClientSecret [get, set]
 Gets or sets the client secret obtained from the API console during application registration.during application registration. More...
 
string Scope [get, set]
 Gets or sets the API access your application is requesting. This is space delimited. More...
 
string State [get, set]
 Gets or sets a parameter that your application can use for keeping state. The OAuth Authorization Server roundtrips this parameter. More...
 
string TokenType [get]
 Gets the type of token returned by the server. This field will always have the value Bearer for now. More...
 
string AccessToken [get, set]
 Gets or sets the token that can be sent to a Google API for authentication. More...
 
DateTime UpdatedOn [get, set]
 Gets or sets the time at which access token was retrieved. More...
 
int ExpiresIn [get, set]
 Gets the remaining lifetime on the access token. More...
 
OAuthTokensObtainedCallback OnOAuthTokensObtained [get]
 Callback triggered when this provider obtains a new access token or refresh token from the OAuth server. More...
 
- Properties inherited from Google.Api.Ads.Common.Lib.Configurable
AppConfig Config [get]
 Gets the application configuration class for this object. More...
 
- Properties inherited from Google.Api.Ads.Common.Lib.AdsOAuthProviderForApplications
bool IsOffline [get, set]
 Indicates if your application needs to access APIs when the user is not present at the browser. This is defaulted to true. More...
 
string RedirectUri [get, set]
 Gets or sets where the url where the response is sent. This should be a registered redirect uri on the API console. More...
 
string RefreshToken [get, set]
 Gets or sets a token that may be used to obtain a new access token. Refresh tokens are valid until the user revokes access. More...
 

Detailed Description

Default implementation of OAuth2 provider.

Constructor & Destructor Documentation

Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.AdsOAuthProviderImpl ( AppConfig  config)
inline

Initializes a new instance of the AdsOAuthProvider class.

Parameters
configThe configuration.

Member Function Documentation

virtual string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.CreateAuthorizationUrl ( )
inlineprotectedvirtual

Creates the authorization URL.

Returns
The authorization URL.
virtual TokenResponse Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.ExchangeCodeForToken ( string  code)
inlineprotectedvirtual

Exchanges the authorization code for access and refresh tokens.

Parameters
codeThe authorization code.
Returns
The token response.
bool Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.FetchAccessAndRefreshTokens ( string  authorizationCode)
inline

Fetches the access and optionally the refresh token if applicable.

Parameters
authorizationCodeThe authorization code returned by OAuth server.
Returns
True if the tokens were fetched successfully, false otherwise.

Implements Google.Api.Ads.Common.Lib.AdsOAuthProviderForApplications.

void Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.GenerateAccessTokenForServiceAccount ( )
inline

Generates the access token for service account.

Implements Google.Api.Ads.Common.Lib.AdsOAuthProviderForServiceAccounts.

virtual TokenResponse Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.GetAccessTokenForAuthorizationCodeFlow ( )
inlineprotectedvirtual

Refreshes the access token in authorization code flow.

Returns
The token response.
virtual TokenResponse Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.GetAccessTokenForServiceAccount ( )
inlineprotectedvirtual

Gets the access token in service account flow.

Returns
The token response.
virtual string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.GetAuthHeader ( )
inlinevirtual

Gets the OAuth authorization header to be used with HTTP requests.

Returns
The authorization header.

Implements Google.Api.Ads.Common.Lib.AdsOAuthProvider.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.GetAuthorizationUrl ( )
inline

Gets the authorization URL.

Implements Google.Api.Ads.Common.Lib.AdsOAuthProviderForApplications.

void Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.RefreshAccessToken ( )
inline

Refreshes the access token if expiring.

Implements Google.Api.Ads.Common.Lib.AdsOAuthProvider.

void Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.RefreshAccessTokenIfExpiring ( )
inline

Refreshes the access token if expiring.

Implements Google.Api.Ads.Common.Lib.AdsOAuthProvider.

void Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.RefreshAccessTokenInOfflineMode ( )
inline

Refreshes the access token if offline mode is used.

Implements Google.Api.Ads.Common.Lib.AdsOAuthProviderForApplications.

void Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.RevokeRefreshToken ( )
inline

Revokes the refresh token if offline mode is used.

Implements Google.Api.Ads.Common.Lib.AdsOAuthProviderForApplications.

virtual void Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.RevokeRefreshToken ( string  refreshToken)
inlineprotectedvirtual

Revokes the refresh token asynchronously.

Parameters
refreshTokenThe refresh token.

Member Data Documentation

readonly AdsFeatureUsageRegistry Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.featureUsageRegistry
protected
Initial value:
=
AdsFeatureUsageRegistry.Instance

The registry for saving feature usage information..

Property Documentation

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.AccessToken
getset

Gets or sets the token that can be sent to a Google API for authentication.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.ClientId
getset

Gets or sets the client that is making the request. This value is obtained from the Google Cloud Console during application registration.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.ClientSecret
getset

Gets or sets the client secret obtained from the Google Cloud Console during application registration.

IClock Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.Clock
getset

The clock used for requesting access tokens.

AppConfig Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.Config = SystemClock.Default
get

Gets the application configuration class for this object.

int Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.ExpiresIn
getset

Gets the remaining lifetime on the access token.

IHttpClientFactory Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.HttpClientFactory
getset

The HttpClientFactory used for requesting access tokens.

bool Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.IsOffline
getset

Indicates if your application needs to access APIs when the user is not present at the browser. This is defaulted to true.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.JwtPrivateKey
get

Gets or sets the JWT private key.

OAuthTokensObtainedCallback Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.OnOAuthTokensObtained
getset

Callback triggered when this provider obtains a new access token or refresh token from the OAuth server.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.PrnEmail
getset

Gets or sets the email of the account for which the call is being made.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.RedirectUri = true
getset

Gets or sets where the url where the response is sent. This should be a registered redirect uri on the Google Cloud Console.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.RefreshToken
getset

Gets or sets a token that may be used to obtain a new access token. Refresh tokens are valid until the user revokes access.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.Scope
getset

Gets or sets the API access your application is requesting. This is space delimited.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.ServiceAccountEmail
get

Gets the service account email for which access token should be retrieved.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.State
getset

Gets or sets a parameter that your application can use for keeping state. The OAuth authorization server roundtrips this parameter.

string Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.TokenType
get

Gets the type of token returned by the server. This field will always have the value Bearer for now.

DateTime Google.Api.Ads.Common.OAuth.AdsOAuthProviderImpl.UpdatedOn
getset

Gets or sets the time at which access token was retrieved.


The documentation for this class was generated from the following file: