-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathEmptyTokenCredential.cs
More file actions
38 lines (36 loc) · 1.56 KB
/
EmptyTokenCredential.cs
File metadata and controls
38 lines (36 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Azure.Core;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.Extensions.Configuration.AzureAppConfiguration.Afd
{
/// <summary>
/// A token credential that provides an empty token.
/// </summary>
internal class EmptyTokenCredential : TokenCredential
{
/// <summary>
/// Gets an empty token.
/// </summary>
/// <param name="requestContext">The context of the token request.</param>
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
/// <returns>An empty access token.</returns>
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
return new AccessToken(string.Empty, DateTimeOffset.MaxValue);
}
/// <summary>
/// Asynchronously gets an empty token.
/// </summary>
/// <param name="requestContext">The context of the token request.</param>
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains an empty access token.</returns>
public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
return new ValueTask<AccessToken>(new AccessToken(string.Empty, DateTimeOffset.MaxValue));
}
}
}