Skip to content

Commit dbb4d9b

Browse files
authored
Merge pull request #5042 from sbwalker/dev
fix logic to retrieve access token
2 parents b06750e + 6775edf commit dbb4d9b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Oqtane.Server/Components/App.razor

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
@using Microsoft.AspNetCore.Localization
88
@using Microsoft.Net.Http.Headers
99
@using Microsoft.Extensions.Primitives
10+
@using Microsoft.AspNetCore.Authentication
1011
@using Oqtane.Client
1112
@using Oqtane.UI
1213
@using Oqtane.Repository
@@ -177,7 +178,7 @@
177178
// get jwt token for downstream APIs
178179
if (Context.User.Identity.IsAuthenticated)
179180
{
180-
GetJwtToken(alias);
181+
await GetJwtToken(alias);
181182
}
182183

183184
// includes resources
@@ -444,15 +445,11 @@
444445
}
445446
}
446447

447-
private void GetJwtToken(Alias alias)
448+
private async Task GetJwtToken(Alias alias)
448449
{
449-
_authorizationToken = Context.Request.Headers[HeaderNames.Authorization];
450-
if (!string.IsNullOrEmpty(_authorizationToken))
451-
{
452-
// bearer token was provided by remote Identity Provider and was persisted using SaveTokens
453-
_authorizationToken = _authorizationToken.Replace("Bearer ", "");
454-
}
455-
else
450+
// bearer token may have been provided by remote Identity Provider and persisted using SaveTokens = true
451+
_authorizationToken = await Context.GetTokenAsync("access_token");
452+
if (string.IsNullOrEmpty(_authorizationToken))
456453
{
457454
// generate bearer token if a secret has been configured in User Settings
458455
var sitesettings = Context.GetSiteSettings();

0 commit comments

Comments
 (0)