Skip to content

Commit

Permalink
Dotnet/http auth (#322)
Browse files Browse the repository at this point in the history
* Dotnet: Cache access token

* Dotnet: VaasFactory for use without DI

---------

Co-authored-by: Philip Stadermann <[email protected]>
  • Loading branch information
doxthree and Philip Stadermann authored Nov 6, 2023
1 parent 5c63190 commit 9bec0ee
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dotnet/Vaas/src/Vaas/VaasFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Net.Http;
using Vaas.Authentication;

namespace Vaas;

public static class VaasFactory
{
private static readonly HttpClient HttpClient = new ();

public static IVaas Create(VaasOptions vaasOptions)
{
var systemClock = new SystemClock();
var authenticator = new Authenticator(HttpClient, systemClock, vaasOptions);

var bearerTokenHandler = new BearerTokenHandler(authenticator);
bearerTokenHandler.InnerHandler = new HttpClientHandler();
var httpClient = new HttpClient(bearerTokenHandler);

return new Vaas(httpClient, authenticator, vaasOptions);
}
}

0 comments on commit 9bec0ee

Please sign in to comment.