microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
dev

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Api/Auth/TokenCredentials.cs

33lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4using Microsoft.Teams.Common.Http;
5
6namespace Microsoft.Teams.Api.Auth;
7
8public delegate Task<ITokenResponse> TokenFactory(string? tenantId, params string[] scopes);
9
10public class TokenCredentials : IHttpCredentials
11{
12 public string ClientId { get; set; }
13 public string? TenantId { get; set; }
14 public TokenFactory Token { get; set; }
15
16 public TokenCredentials(string clientId, TokenFactory token)
17 {
18 ClientId = clientId;
19 Token = token;
20 }
21
22 public TokenCredentials(string clientId, string tenantId, TokenFactory token)
23 {
24 ClientId = clientId;
25 TenantId = tenantId;
26 Token = token;
27 }
28
29 public async Task<ITokenResponse> Resolve(IHttpClient _client, string[] scopes, CancellationToken cancellationToken = default)
30 {
31 return await Token(TenantId, scopes);
32 }
33}