Class OAuth2Client
Implements
Inherited Members
Namespace: GitCredentialManager.Authentication.OAuth
Assembly: Algenta.Colectica.Repository.Client.dll
Syntax
public class OAuth2Client : IOAuth2Client
Constructors
OAuth2Client(HttpClient, OAuth2ServerEndpoints, string, Uri, string)
Declaration
public OAuth2Client(HttpClient httpClient, OAuth2ServerEndpoints endpoints, string clientId, Uri redirectUri = null, string clientSecret = null)
Parameters
Type | Name | Description |
---|---|---|
HttpClient | httpClient | |
OAuth2ServerEndpoints | endpoints | |
string | clientId | |
Uri | redirectUri | |
string | clientSecret |
Properties
CodeGenerator
Declaration
public IOAuth2CodeGenerator CodeGenerator { get; set; }
Property Value
Type | Description |
---|---|
IOAuth2CodeGenerator |
Methods
GetAuthorizationCodeAsync(IEnumerable<string>, IOAuth2WebBrowser, CancellationToken)
Retrieve an authorization code grant using a user agent.
Declaration
public Task<OAuth2AuthorizationCodeResult> GetAuthorizationCodeAsync(IEnumerable<string> scopes, IOAuth2WebBrowser browser, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<string> | scopes | Scopes to request. |
IOAuth2WebBrowser | browser | User agent to use to start the authorization code grant flow. |
CancellationToken | ct | Token to cancel the operation. |
Returns
Type | Description |
---|---|
Task<OAuth2AuthorizationCodeResult> | Authorization code. |
GetDeviceCodeAsync(IEnumerable<string>, CancellationToken)
Retrieve a device code grant.
Declaration
public Task<OAuth2DeviceCodeResult> GetDeviceCodeAsync(IEnumerable<string> scopes, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<string> | scopes | Scopes to request. |
CancellationToken | ct | Token to cancel the operation. |
Returns
Type | Description |
---|---|
Task<OAuth2DeviceCodeResult> | Device code grant result. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the client has not been configured with a device authorization endpoint. |
GetTokenByAuthorizationCodeAsync(OAuth2AuthorizationCodeResult, CancellationToken)
Exchange an authorization code acquired from GetAuthorizationCodeAsync(IEnumerable<string>, IOAuth2WebBrowser, CancellationToken) for an access token.
Declaration
public Task<OAuth2TokenResult> GetTokenByAuthorizationCodeAsync(OAuth2AuthorizationCodeResult authorizationCodeResult, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
OAuth2AuthorizationCodeResult | authorizationCodeResult | Authorization code grant result. |
CancellationToken | ct | Token to cancel the operation. |
Returns
Type | Description |
---|---|
Task<OAuth2TokenResult> | Token result. |
GetTokenByDeviceCodeAsync(OAuth2DeviceCodeResult, CancellationToken)
Exchange a device code grant acquired from GetDeviceCodeAsync(IEnumerable<string>, CancellationToken) for an access token.
Declaration
public Task<OAuth2TokenResult> GetTokenByDeviceCodeAsync(OAuth2DeviceCodeResult deviceCodeResult, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
OAuth2DeviceCodeResult | deviceCodeResult | Device code grant result. |
CancellationToken | ct | Token to cancel the operation. |
Returns
Type | Description |
---|---|
Task<OAuth2TokenResult> | Token result. |
GetTokenByRefreshTokenAsync(string, CancellationToken)
Use a refresh token to get a new access token.
Declaration
public Task<OAuth2TokenResult> GetTokenByRefreshTokenAsync(string refreshToken, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
string | refreshToken | Refresh token. |
CancellationToken | ct | Token to cancel the operation. |
Returns
Type | Description |
---|---|
Task<OAuth2TokenResult> | Token result. |
TryCreateExceptionFromResponse(string, out OAuth2Exception)
Declaration
protected virtual bool TryCreateExceptionFromResponse(string json, out OAuth2Exception exception)
Parameters
Type | Name | Description |
---|---|---|
string | json | |
OAuth2Exception | exception |
Returns
Type | Description |
---|---|
bool |
TryCreateTokenEndpointResult(string, out OAuth2TokenResult)
Declaration
protected virtual bool TryCreateTokenEndpointResult(string json, out OAuth2TokenResult result)
Parameters
Type | Name | Description |
---|---|---|
string | json | |
OAuth2TokenResult | result |
Returns
Type | Description |
---|---|
bool |
TryDeserializeJson<T>(string, out T)
Declaration
protected static bool TryDeserializeJson<T>(string json, out T obj)
Parameters
Type | Name | Description |
---|---|---|
string | json | |
T | obj |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T |