Open Closed

While using angular-oauth2-oidc package in angular app. Whenever I try to login, It appears to be removing the access_token and id_token from localStorage. #8371


User avatar
0
Sergei.Gorlovetsky created
  • ABP Framework version: v8.3.2
  • UI Type: Angular
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: While using angular-oauth2-oidc package in angular app. Whenever I try to login, It appears to be removing the access_token and id_token from localStorage.
  • Steps to reproduce the issue: 1- Use IdentityServer for authentication. 2- Use angular-oauth2-oidc package in angular app. 3- Inject OAuthService in home.component.ts 4 - Try to debug the this.oAuthService.hasValidAccessToken() method, access_token and id_token firstly stored then somehow removed from localStorage.

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    could you share a test project? I will check it.shiwei.liang@volosoft.com

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    You can try

    ClientelePortalHttpApiHostModule

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        .....
        MapClaims();
    }
    private void MapClaims()
    {
        AbpClaimTypes.UserName = ClaimTypes.Name;
        AbpClaimTypes.Name = ClaimTypes.GivenName;
        AbpClaimTypes.SurName = ClaimTypes.Surname;
        AbpClaimTypes.UserId = ClaimTypes.NameIdentifier;
        AbpClaimTypes.Role = ClaimTypes.Role;
        AbpClaimTypes.Email = ClaimTypes.Email;
    }
    

    Update oAuthConfig

    const oAuthConfig = {
      issuer: identityServerUrl,
      redirectUri: baseUrl,
      clientId: 'ClientelePortal_App',
      skipIssuerCheck: true,
      responseType: 'code',
      scope: 'offline_access ClientelePortal'
    }; 
    
  • User Avatar
    0
    Sergei.Gorlovetsky created

    Hi Liangshiwei, Thank you for the suggestion. We've applied it and it worked. Have a great weekend :)

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15