Class StaticBearerTokenProvider
- Namespace
- Line.OpenApi.Core.Authentication
- Assembly
- Line.OpenApi.Core.dll
Generic provider that holds and returns a single Bearer token, gated by an allow list of hosts. It is the credential-agnostic counterpart of StaticChannelAccessTokenProvider: use it to attach a caller-supplied token (for example a LINE Login user access token) to requests, while ensuring the token is never sent to a host outside the allow list.
Like StaticChannelAccessTokenProvider, it wires into Kiota's Microsoft.Kiota.Abstractions.Authentication.BaseBearerTokenAuthenticationProvider as an Microsoft.Kiota.Abstractions.Authentication.IAccessTokenProvider. It is kept as a distinct type (rather than folding the channel-token provider into it) so each usage keeps a self-describing name at the call site.
public sealed class StaticBearerTokenProvider : IAccessTokenProvider
- Inheritance
-
StaticBearerTokenProvider
- Implements
-
IAccessTokenProvider
- Inherited Members
Constructors
StaticBearerTokenProvider(string, params string[])
public StaticBearerTokenProvider(string token, params string[] allowedHosts)
Parameters
tokenstringThe Bearer token to attach.
allowedHostsstring[]Hosts the token may be attached to. When empty, the Bot/Messaging default (Default) is used.
Properties
AllowedHostsValidator
Returns the Microsoft.Kiota.Abstractions.Authentication.IAccessTokenProvider.AllowedHostsValidator for the provider.
public AllowedHostsValidator AllowedHostsValidator { get; }
Property Value
- AllowedHostsValidator
Methods
GetAuthorizationTokenAsync(Uri, Dictionary<string, object>?, CancellationToken)
This method is called by the Microsoft.Kiota.Abstractions.Authentication.BaseBearerTokenAuthenticationProvider class to get the access token.
public Task<string> GetAuthorizationTokenAsync(Uri uri, Dictionary<string, object>? additionalAuthenticationContext = null, CancellationToken cancellationToken = default)
Parameters
uriUriThe target URI to get an access token for.
additionalAuthenticationContextDictionary<string, object>Additional authentication context to pass to the authentication library.
cancellationTokenCancellationTokenThe cancellation token for the task