microsoft/healthcare-shared-components

Public

mirrored from https://github.com/microsoft/healthcare-shared-componentsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
main

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Microsoft.Health.Client/Authentication/NamedCredentialProvider.cs

31lines · modecode

1// -------------------------------------------------------------------------------------------------
2// Copyright (c) Microsoft Corporation. All rights reserved.
3// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
4// -------------------------------------------------------------------------------------------------
5
6using System.Threading;
7using System.Threading.Tasks;
8using EnsureThat;
9
10namespace Microsoft.Health.Client.Authentication;
11
12public class NamedCredentialProvider : ICredentialProvider
13{
14 private readonly ICredentialProvider _credentialProvider;
15
16 public NamedCredentialProvider(string name, ICredentialProvider credentialProvider)
17 {
18 EnsureArg.IsNotNull(name, nameof(name));
19 EnsureArg.IsNotNull(credentialProvider, nameof(credentialProvider));
20
21 Name = name;
22 _credentialProvider = credentialProvider;
23 }
24
25 public string Name { get; }
26
27 public Task<string> GetBearerTokenAsync(CancellationToken cancellationToken)
28 {
29 return _credentialProvider.GetBearerTokenAsync(cancellationToken);
30 }
31}
32