C# Класс Google.PowerShell.Common.AuthenticateWithSdkCredentialsExecutor

OAuth 2.0 credential for accessing protected resources using an access token. This class will get the access token from "gcloud auth print-access-token".
Наследование: ICredential, IHttpExecuteInterceptor, IHttpUnsuccessfulResponseHandler
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
GetAccessTokenForRequestAsync ( string authUri = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task
HandleResponseAsync ( Google.Apis.Http.HandleUnsuccessfulResponseArgs args ) : Task

Handles an abnormal response when sending a HTTP request. A simple rule must be followed, if you modify the request object in a way that the abnormal response can be resolved, you must return true.

Initialize ( Google.Apis.Http.ConfigurableHttpClient httpClient ) : void
InterceptAsync ( HttpRequestMessage request, CancellationToken taskCancellationToken ) : Task

Default implementation is to try to refresh the access token if there is no access token or if we are 1 minute away from expiration. If token server is unavailable, it will try to use the access token even if has expired. If successful, it will call IAccessMethod.Intercept.

RefreshTokenAsync ( CancellationToken taskCancellationToken ) : Task

Refreshes the token by calling to ActiveUserConfig.GetActiveUserToken

RevokeTokenAsync ( CancellationToken taskCancellationToken ) : Task

Asynchronously revokes the token by calling Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.RevokeTokenAsync.

Описание методов

GetAccessTokenForRequestAsync() публичный Метод

public GetAccessTokenForRequestAsync ( string authUri = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task
authUri string
cancellationToken System.Threading.CancellationToken
Результат Task

HandleResponseAsync() публичный Метод

Handles an abnormal response when sending a HTTP request. A simple rule must be followed, if you modify the request object in a way that the abnormal response can be resolved, you must return true.
public HandleResponseAsync ( Google.Apis.Http.HandleUnsuccessfulResponseArgs args ) : Task
args Google.Apis.Http.HandleUnsuccessfulResponseArgs
Результат Task

Initialize() публичный Метод

public Initialize ( Google.Apis.Http.ConfigurableHttpClient httpClient ) : void
httpClient Google.Apis.Http.ConfigurableHttpClient
Результат void

InterceptAsync() публичный Метод

Default implementation is to try to refresh the access token if there is no access token or if we are 1 minute away from expiration. If token server is unavailable, it will try to use the access token even if has expired. If successful, it will call IAccessMethod.Intercept.
public InterceptAsync ( HttpRequestMessage request, CancellationToken taskCancellationToken ) : Task
request System.Net.Http.HttpRequestMessage
taskCancellationToken System.Threading.CancellationToken
Результат Task

RefreshTokenAsync() публичный Метод

Refreshes the token by calling to ActiveUserConfig.GetActiveUserToken
public RefreshTokenAsync ( CancellationToken taskCancellationToken ) : Task
taskCancellationToken System.Threading.CancellationToken
Результат Task

RevokeTokenAsync() публичный Метод

Asynchronously revokes the token by calling Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.RevokeTokenAsync.
public RevokeTokenAsync ( CancellationToken taskCancellationToken ) : Task
taskCancellationToken System.Threading.CancellationToken Cancellation token to cancel an operation.
Результат Task