Class Authenticator
Authenticator that issues a POST request to an authority endpoint defined in the Authority configuration in order to obtain bearer access tokens. The token is cached and renewed if it expired
Implements
Inherited Members
Namespace: Cognite.Extensions
Assembly: Cognite.Extensions.dll
Syntax
public class Authenticator : IAuthenticator
Constructors
| Edit this page View SourceAuthenticator(AuthenticatorConfig, HttpClient, ILogger<IAuthenticator>?)
Creates a new authenticator
Declaration
public Authenticator(AuthenticatorConfig config, HttpClient client, ILogger<IAuthenticator>? logger)
Parameters
Type | Name | Description |
---|---|---|
AuthenticatorConfig | config | Configuration object |
HttpClient | client | Http client |
ILogger<IAuthenticator> | logger | Logger |
Methods
| Edit this page View SourceGetToken(CancellationToken)
Request a token and cache it until it expires.
Declaration
public Task<string?> GetToken(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<string> | A valid bearer access token |
Exceptions
Type | Condition |
---|---|
CogniteUtilsException | Thrown when it was not possible to obtain an authentication token. |