Class DefaultAuthTokenProvider
The default authentication token provider.
Inheritance
Implements
Namespace: anybill.POS.Client.Authentication
Assembly: anybill.POS.Client.dll
Syntax
public class DefaultAuthTokenProvider : IAuthTokenProvider
Constructors
DefaultAuthTokenProvider(IAnybillAuthenticationOptions)
Creates a new instance with minimum configuration.
Declaration
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions)
Parameters
Type | Name | Description |
---|---|---|
IAnybillAuthenticationOptions | anybillAuthenticationOptions | The authentication options to use. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If |
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, IDefaultAuthTokenProviderOptions, IAnybillSerializer, HttpClient, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
Declaration
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, IDefaultAuthTokenProviderOptions defaultAuthTokenProviderOptions, IAnybillSerializer anybillSerializer, HttpClient httpClient, ILogger<DefaultAuthTokenProvider> logger)
Parameters
Type | Name | Description |
---|---|---|
IAnybillAuthenticationOptions | anybillAuthenticationOptions | The authentication options to use. |
IDefaultAuthTokenProviderOptions | defaultAuthTokenProviderOptions | The custom auth service options to use. |
IAnybillSerializer | anybillSerializer | The IAnybillSerializer to use. |
System.Net.Http.HttpClient | httpClient | The http client to use. |
Microsoft.Extensions.Logging.ILogger<DefaultAuthTokenProvider> | logger | The logger to use |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If |
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, IDefaultAuthTokenProviderOptions, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
Declaration
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, IDefaultAuthTokenProviderOptions defaultAuthTokenProviderOptions, ILogger<DefaultAuthTokenProvider> logger)
Parameters
Type | Name | Description |
---|---|---|
IAnybillAuthenticationOptions | anybillAuthenticationOptions | The authentication options to use. |
IDefaultAuthTokenProviderOptions | defaultAuthTokenProviderOptions | The custom auth service options to use. |
Microsoft.Extensions.Logging.ILogger<DefaultAuthTokenProvider> | logger | The logger to use |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If |
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, IDefaultAuthTokenProviderOptions, HttpClient, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
Declaration
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, IDefaultAuthTokenProviderOptions defaultAuthTokenProviderOptions, HttpClient httpClient, ILogger<DefaultAuthTokenProvider> logger)
Parameters
Type | Name | Description |
---|---|---|
IAnybillAuthenticationOptions | anybillAuthenticationOptions | The authentication options to use. |
IDefaultAuthTokenProviderOptions | defaultAuthTokenProviderOptions | The custom auth service options to use. |
System.Net.Http.HttpClient | httpClient | The http client to use. |
Microsoft.Extensions.Logging.ILogger<DefaultAuthTokenProvider> | logger | The logger to use |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If |
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
Declaration
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, ILogger<DefaultAuthTokenProvider> logger)
Parameters
Type | Name | Description |
---|---|---|
IAnybillAuthenticationOptions | anybillAuthenticationOptions | The authentication options to use. |
Microsoft.Extensions.Logging.ILogger<DefaultAuthTokenProvider> | logger | The logger to use |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If |
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, HttpClient, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
Declaration
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, HttpClient httpClient, ILogger<DefaultAuthTokenProvider> logger)
Parameters
Type | Name | Description |
---|---|---|
IAnybillAuthenticationOptions | anybillAuthenticationOptions | The authentication options to use. |
System.Net.Http.HttpClient | httpClient | The http client to use. |
Microsoft.Extensions.Logging.ILogger<DefaultAuthTokenProvider> | logger | The logger to use |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If |
Methods
GetAsync(Boolean, CancellationToken)
Returns an auth token.
Declaration
public async Task<string> GetAsync(bool reAuthenticate, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | reAuthenticate | Whether to reset the state. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | An auth token. |
Remarks
Can be used to test authentication. Set reAuthenticate
to reset the state.
Exceptions
Type | Condition |
---|---|
AuthenticationException | If an error occured while authentication. |
GetAsync(CancellationToken)
Returns an auth token.
Declaration
public async Task<string> GetAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | An auth token. |
Remarks
Can be used to test authentication.
Exceptions
Type | Condition |
---|---|
AuthenticationException | If an error occured while authentication. |
SetAnybillAuthenticationOptions(IAnybillAuthenticationOptions)
Updates the current authentication options.
Declaration
public void SetAnybillAuthenticationOptions(IAnybillAuthenticationOptions anybillAuthenticationOptions)
Parameters
Type | Name | Description |
---|---|---|
IAnybillAuthenticationOptions | anybillAuthenticationOptions | The updated authentication options to use. |
Remarks
Resets the current cached authentication token.
UseCustomSerializer(IAnybillSerializer)
Use a custom serializer.
Declaration
public void UseCustomSerializer(IAnybillSerializer anybillSerializer)
Parameters
Type | Name | Description |
---|---|---|
IAnybillSerializer | anybillSerializer | The custom serializer. |