Add all-gyms
Some checks failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
ci/woodpecker/pr/build Pipeline failed
ci/woodpecker/pr/all-checks-complete unknown status

This commit is contained in:
Smaug123
2024-02-12 21:52:11 +00:00
parent f182c6ebad
commit 43c87c7955
6 changed files with 74 additions and 9 deletions

View File

@@ -23,21 +23,23 @@ module Api =
let cache = new Cache<_> (AuthToken.get cred, _.ExpiryTime)
cache :> _, (fun () -> Async.RunSynchronously (cache.GetCurrentValue ()))
task {
async {
let client = new HttpClient ()
return PureGymApi.make (getToken >> _.AccessToken >> sprintf "Bearer %s") client, cache
}
|> Async.StartAsTask
/// Create a REST client, authenticated as the specified user. Do not refresh creds.
let makeWithoutRefresh (ct : CancellationToken) (auth : Auth) : IPureGymApi Task =
task {
async {
let! token =
match auth with
| Auth.Token t -> Task.FromResult<_> t
| Auth.User cred -> AuthToken.get cred ct
| Auth.Token t -> async.Return t
| Auth.User cred -> Async.AwaitTask (AuthToken.get cred ct)
let client = new HttpClient ()
return PureGymApi.make (fun () -> $"Bearer %s{token.AccessToken}") client
}
|> Async.StartAsTask