waives / waives.net

The .NET SDK for Waives
https://docs.waives.io/docs/dotnet-sdk-overview
MIT License
0 stars 0 forks source link

Renew access tokens when they expire #72

Closed alastairs closed 5 years ago

alastairs commented 5 years ago

This PR utilises Polly's cache policy and the Microsoft MemoryCache to store the access token until it expires. The TTL on the cache item is determined from the Access Token response.

The Access Token cache is invoked at the top level of the decorator chain, and access token requests use all underlying decorators. In order to create a WaivesClient, consumers should now make the following chained call:

WaivesClient.Create().Login("my-client-id", "my-client-secret")

Note that omitting the Login() call will result in a WaivesClient that can be used against an API deployment with no authentication.

Fixes #10.