u
This commit is contained in:
@@ -50,7 +50,16 @@ public static class ConfigureServices
|
||||
{
|
||||
var credentials = CallCredentials.FromInterceptor(async (context, metadata) =>
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
// Get token from local storage if available
|
||||
var localStorage = serviceProvider.GetService(typeof(ILocalStorageService)) as ILocalStorageService;
|
||||
if (localStorage != null)
|
||||
{
|
||||
var token = await localStorage.GetItemAsync<string>("auth:token");
|
||||
if (!string.IsNullOrWhiteSpace(token))
|
||||
{
|
||||
metadata.Add("Authorization", $"Bearer {token}");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// SslCredentials is used here because this channel is using TLS.
|
||||
|
||||
Reference in New Issue
Block a user