From 6e7eb51ffe7c0f9835a63a1e992da230b56cc1bb Mon Sep 17 00:00:00 2001 From: Alexander Forbes-Reed Date: Tue, 28 Apr 2020 18:14:38 +0100 Subject: [PATCH] Token changes --- dotnet/Services/Token/App/GetXblToken.cs | 1 + dotnet/Services/Token/Client.cs | 28 ++++++++++++++++++++++++ dotnet/Services/Token/README.md | 3 ++- dotnet/Services/Token/Service.cs | 2 ++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 dotnet/Services/Token/Client.cs diff --git a/dotnet/Services/Token/App/GetXblToken.cs b/dotnet/Services/Token/App/GetXblToken.cs index 72b9427b..85bcc6e2 100644 --- a/dotnet/Services/Token/App/GetXblToken.cs +++ b/dotnet/Services/Token/App/GetXblToken.cs @@ -73,6 +73,7 @@ await Task.WhenAll( { CacheInfo = new CacheInfo(token.IssueInstant, token.NotAfter), Token = token.Token, + Uhs = token.DisplayClaims.Xui[0].Uhs, }; client.Set(XblRedisKey, JsonConvert.SerializeObject(response), (DateTime) response.CacheInfo.ExpiresAt); diff --git a/dotnet/Services/Token/Client.cs b/dotnet/Services/Token/Client.cs new file mode 100644 index 00000000..4fa68e49 --- /dev/null +++ b/dotnet/Services/Token/Client.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Branch.Global.Contracts; +using Branch.Global.Libraries; +using Microsoft.AspNetCore.Http; + +namespace Branch.Services.Token +{ + public class TokenClient : ITokenService + { + private JsonClient _client { get; } + + public TokenClient(string baseUrl, string key) + { + var options = new HttpClientOptions + { + Headers = new Dictionary { { "Authorization", $"bearer {key}" } }, + }; + + _client = new JsonClient(baseUrl, options); + } + + public async Task GetXblToken(HttpContext ctx, GetTokenRequest req) + { + return await _client.Do("POST", "1/2020-04-27/get_xbl_token", req); + } + } +} diff --git a/dotnet/Services/Token/README.md b/dotnet/Services/Token/README.md index cd8eafd1..5f036520 100644 --- a/dotnet/Services/Token/README.md +++ b/dotnet/Services/Token/README.md @@ -32,7 +32,8 @@ BaseURL: https://service-token.branch.golf/1 "cached_at": "2020-04-26T23:00:02.168Z", "expires_at": "2020-04-26T23:15:13.614Z" }, - "token": "blah blah" + "token": "blah blah", + "uhs": "blah" } ``` diff --git a/dotnet/Services/Token/Service.cs b/dotnet/Services/Token/Service.cs index 1d476640..4d963f0f 100644 --- a/dotnet/Services/Token/Service.cs +++ b/dotnet/Services/Token/Service.cs @@ -19,5 +19,7 @@ public class GetXblTokenResponse : IBranchResponse public CacheInfo CacheInfo { get; set; } public string Token { get; set; } + + public string Uhs { get; set; } } }