Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
049f0e6
commit cf65711
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Options; | ||
using Microsoft.Rest; | ||
// ReSharper disable CheckNamespace | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
internal class StreetcredClientCredentials : ServiceClientCredentials | ||
{ | ||
/// <summary> | ||
/// Gets the options. | ||
/// </summary> | ||
/// <value> | ||
/// The options. | ||
/// </value> | ||
public ServiceClientOptions Options { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="StreetcredClientCredentials"/> class. | ||
/// </summary> | ||
/// <param name="options">The options.</param> | ||
public StreetcredClientCredentials(IOptions<ServiceClientOptions> options) | ||
{ | ||
Options = options.Value; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken) | ||
{ | ||
request.Headers.Add("Authorization", $"Bearer {Options.AccessToken}"); | ||
request.Headers.Add("X-Streetcred-Subscription-Key", Options.SubscriptionKey); | ||
return base.ProcessHttpRequestAsync(request, cancellationToken); | ||
} | ||
} | ||
} |