-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
TokenCredential.cs
34 lines (31 loc) · 1.93 KB
/
TokenCredential.cs
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Threading;
using System.Threading.Tasks;
namespace Azure.Core
{
/// <summary>
/// Represents a credential capable of providing an OAuth token.
/// </summary>
public abstract class TokenCredential
{
/// <summary>
/// Gets an <see cref="AccessToken"/> for the specified set of scopes.
/// </summary>
/// <param name="requestContext">The <see cref="TokenRequestContext"/> with authentication information.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param>
/// <returns>A valid <see cref="AccessToken"/>.</returns>
/// <remarks>Caching and management of the lifespan for the <see cref="AccessToken"/> is considered the responsibility of the caller: each call should request a fresh token being requested.</remarks>
[CallerShouldAudit("https://aka.ms/azsdk/callershouldaudit/identity")]
public abstract ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken);
/// <summary>
/// Gets an <see cref="AccessToken"/> for the specified set of scopes.
/// </summary>
/// <param name="requestContext">The <see cref="TokenRequestContext"/> with authentication information.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param>
/// <returns>A valid <see cref="AccessToken"/>.</returns>
/// <remarks>Caching and management of the lifespan for the <see cref="AccessToken"/> is considered the responsibility of the caller: each call should request a fresh token being requested.</remarks>
[CallerShouldAudit("https://aka.ms/azsdk/callershouldaudit/identity")]
public abstract AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken);
}
}