Skip to content

Instantly share code, notes, and snippets.

@mr5z
Created February 17, 2024 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mr5z/916800453a81e3daa27fabf10dd9aaf3 to your computer and use it in GitHub Desktop.
Save mr5z/916800453a81e3daa27fabf10dd9aaf3 to your computer and use it in GitHub Desktop.
Android.Maui - Seriously?
public async Task<TokenResponse> GetTokenResponse()
{
var raw = Task.Run(async () => await SecureStorage.GetAsync(KeyTokenResponse)).Result
?? throw new InvalidOperationException($"'{nameof(TokenResponse)}' not found");
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(raw), false);
return await JsonSerializer.DeserializeAsync<TokenResponse>(stream)
?? throw new InvalidOperationException($"Cannot deserialize '{nameof(TokenResponse)}'");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment