Class MsalAuthenticator
Uses Microsoft Authentication Library (MSAL) to acquire tokens from the identity provider endpoint defined in the Authority configuration
Implements
Inherited Members
Namespace: Cognite.Extensions
Assembly: Cognite.Extensions.dll
Syntax
public class MsalAuthenticator : IAuthenticator
Constructors
| Edit this page View SourceMsalAuthenticator(AuthenticatorConfig, ILogger<IAuthenticator>, IHttpClientFactory, string)
Creates a new MSAL authenticator
Declaration
public MsalAuthenticator(AuthenticatorConfig config, ILogger<IAuthenticator> logger, IHttpClientFactory httpClientFactory, string authClientName)
Parameters
Type | Name | Description |
---|---|---|
AuthenticatorConfig | config | Configuration object |
ILogger<IAuthenticator> | logger | Logger |
IHttpClientFactory | httpClientFactory | Http client factory used by this authenticator |
string | authClientName | Name of http client. Used by the factory to instantiate a pre-configured client |
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. |