Skip to content

Commit

Permalink
Remove offline_access
Browse files Browse the repository at this point in the history
  • Loading branch information
Roland Guijt committed Jul 22, 2024
1 parent 5338a4a commit 73db265
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public static class Config
// where to redirect to after logout
PostLogoutRedirectUris = { "https://localhost:5002/signout-callback-oidc" },

AllowOfflineAccess = true,

AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using System.Net.Http.Headers;
using System.Text.Json;
using IdentityModel.Client;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace MyApp.Namespace
{

public class CallApiModel(IHttpClientFactory httpClientFactory) : PageModel
public class CallApiModel() : PageModel
{
public string Json = string.Empty;

public async Task OnGet()
{
var accessToken = await HttpContext.GetUserAccessTokenAsync();
var client = httpClientFactory.CreateClient();
client.SetBearerToken(accessToken.AccessToken!);
var accessToken = await HttpContext.GetTokenAsync("access_token");
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

var content = await client.GetStringAsync("https://localhost:6001/identity");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
options.Scope.Add("openid");
options.Scope.Add("profile");
options.Scope.Add("api1");
options.Scope.Add("offline_access");
options.Scope.Add("verification");
options.ClaimActions.MapJsonKey("email_verified", "email_verified");
options.GetClaimsFromUserInfoEndpoint = true;
Expand All @@ -32,9 +31,6 @@
options.SaveTokens = true;
});

builder.Services.AddHttpClient();
builder.Services.AddOpenIdConnectAccessTokenManagement();

var app = builder.Build();

// Configure the HTTP request pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.AccessTokenManagement.OpenIdConnect" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.7" />
</ItemGroup>

Expand Down

0 comments on commit 73db265

Please sign in to comment.