// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; namespace k8s.Authentication { /// /// A simple token provider that always provides a static access token. /// public sealed class StringTokenProvider : ITokenProvider { private readonly string _accessToken; private readonly string _type; /// /// Initializes a new instance of the class. /// Create a token provider for the given token type that returns the given /// access token. /// /// The access token to return. /// The token type of the given access token. public StringTokenProvider(string accessToken, string tokenType) { _accessToken = accessToken; _type = tokenType; } /// /// Gets the token type of this access token. /// public string TokenType => _type; /// /// Returns the static access token. /// /// The cancellation token for this action. /// This will not be used since the returned token is static. /// The access token. public Task GetAuthenticationHeaderAsync(CancellationToken cancellationToken) { return Task.FromResult(new AuthenticationHeaderValue(_type, _accessToken)); } } }