Class DefaultAuthTokenProvider
- Namespace
- anybill.POS.Client.Authentication
- Assembly
- anybill.POS.Client.dll
The default authentication token provider.
public class DefaultAuthTokenProvider : IAuthTokenProvider
- Inheritance
-
DefaultAuthTokenProvider
- Implements
- Inherited Members
Constructors
DefaultAuthTokenProvider(IAnybillAuthenticationOptions)
Creates a new instance with minimum configuration.
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions)
Parameters
anybillAuthenticationOptions
IAnybillAuthenticationOptionsThe authentication options to use.
Exceptions
- ArgumentException
If
anybillAuthenticationOptions
is null.
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, ILogger<DefaultAuthTokenProvider> logger)
Parameters
anybillAuthenticationOptions
IAnybillAuthenticationOptionsThe authentication options to use.
logger
ILogger<DefaultAuthTokenProvider>The logger to use
Exceptions
- ArgumentException
If
anybillAuthenticationOptions
is null.
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, HttpClient, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, HttpClient httpClient, ILogger<DefaultAuthTokenProvider> logger)
Parameters
anybillAuthenticationOptions
IAnybillAuthenticationOptionsThe authentication options to use.
httpClient
HttpClientThe http client to use.
logger
ILogger<DefaultAuthTokenProvider>The logger to use
Exceptions
- ArgumentException
If
anybillAuthenticationOptions
is null.
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, IDefaultAuthTokenProviderOptions, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, IDefaultAuthTokenProviderOptions defaultAuthTokenProviderOptions, ILogger<DefaultAuthTokenProvider> logger)
Parameters
anybillAuthenticationOptions
IAnybillAuthenticationOptionsThe authentication options to use.
defaultAuthTokenProviderOptions
IDefaultAuthTokenProviderOptionsThe custom auth service options to use.
logger
ILogger<DefaultAuthTokenProvider>The logger to use
Exceptions
- ArgumentException
If
anybillAuthenticationOptions
is null.
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, IDefaultAuthTokenProviderOptions, HttpClient, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, IDefaultAuthTokenProviderOptions defaultAuthTokenProviderOptions, HttpClient httpClient, ILogger<DefaultAuthTokenProvider> logger)
Parameters
anybillAuthenticationOptions
IAnybillAuthenticationOptionsThe authentication options to use.
defaultAuthTokenProviderOptions
IDefaultAuthTokenProviderOptionsThe custom auth service options to use.
httpClient
HttpClientThe http client to use.
logger
ILogger<DefaultAuthTokenProvider>The logger to use
Exceptions
- ArgumentException
If
anybillAuthenticationOptions
is null.
DefaultAuthTokenProvider(IAnybillAuthenticationOptions, IDefaultAuthTokenProviderOptions, IAnybillSerializer, HttpClient, ILogger<DefaultAuthTokenProvider>)
Creates a new instance.
public DefaultAuthTokenProvider(IAnybillAuthenticationOptions anybillAuthenticationOptions, IDefaultAuthTokenProviderOptions defaultAuthTokenProviderOptions, IAnybillSerializer anybillSerializer, HttpClient httpClient, ILogger<DefaultAuthTokenProvider> logger)
Parameters
anybillAuthenticationOptions
IAnybillAuthenticationOptionsThe authentication options to use.
defaultAuthTokenProviderOptions
IDefaultAuthTokenProviderOptionsThe custom auth service options to use.
anybillSerializer
IAnybillSerializerThe IAnybillSerializer to use.
httpClient
HttpClientThe http client to use.
logger
ILogger<DefaultAuthTokenProvider>The logger to use
Exceptions
- ArgumentException
If
anybillAuthenticationOptions
is null.
Methods
GetAsync(bool, CancellationToken)
Returns an auth token.
public Task<string> GetAsync(bool reAuthenticate, CancellationToken cancellationToken)
Parameters
reAuthenticate
boolWhether to reset the state.
cancellationToken
CancellationTokenThe cancellation token.
Returns
Remarks
Can be used to test authentication. Set reAuthenticate
to reset the state.
Exceptions
- AuthenticationException
If an error occured while authentication.
GetAsync(CancellationToken)
Returns an auth token.
public Task<string> GetAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
Remarks
Can be used to test authentication.
Exceptions
- AuthenticationException
If an error occured while authentication.
SetAnybillAuthenticationOptions(IAnybillAuthenticationOptions)
Updates the current authentication options.
public void SetAnybillAuthenticationOptions(IAnybillAuthenticationOptions anybillAuthenticationOptions)
Parameters
anybillAuthenticationOptions
IAnybillAuthenticationOptionsThe updated authentication options to use.
Remarks
Resets the current cached authentication token.
UseCustomSerializer(IAnybillSerializer)
Use a custom serializer.
public void UseCustomSerializer(IAnybillSerializer anybillSerializer)
Parameters
anybillSerializer
IAnybillSerializerThe custom serializer.