Open Closed

Authorization in Angular with token #7803


User avatar
0
nabass created

Hi i'v some errors 1- when running angular application when clicking login i got this error

2- is postman i tried login API and i got access token how to create method to send this token to header for allowing me put any API request and make it valid for view

for example: when i create my http request at first i must go to backend and give this api permission so i want to skip this step to allow angular application create http request from any where so how to send this token when login ?? or ABP offers me this logic automatically ??

thanks

  • ABP Framework version: v8
  • UI Type: Angular
  • Database System: EF Core (SQL Server)

12 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please check the logs.txt to see the error details.

    Angular will get an access token after signing in.

  • User Avatar
    0
    nabass created

    hi where can i find this file?? note : i used external API not api that abp offers me when creating abp angular application

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The Logs.txt is in your startup project folder.

    Project.Web/Logs/logs.txt

    .WriteTo.Async(c => c.File("Logs/logs.txt"))

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Angular project uses https://github.com/manfredsteyer/angular-oauth2-oidc to get tokens. https://github.com/manfredsteyer/angular-oauth2-oidc/blob/master/projects/lib/src/oauth-service.ts#L2378-L2385

  • User Avatar
    0
    nabass created

    hi when i start application i got my port 4200

    when clicking login path changes to

    i created new abp angular application to see url and i found it

    and database like

    so i added in my database new line like

    and changed the url manually to this img (this is wrong i want it to open automatically)

    and when write user name and password url changed again and i got this error

    this is my environment

    note: see this question with your friend "liangshiwei" i have external solution with api not the core project that generated with angular i mean i just use angular https://abp.io/support/questions/7771/Angular-error-API-Response

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Different projects will have different port and ClientId, scope names.

    Please check the logs to see which scope is wrong.

  • User Avatar
    0
    nabass created

    same error i already have different port as i mentioned in oAuthConfig and i created new clientId in database see the image again where can i get the scope ??

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    The offline_access scope needs the OpenIddictConstants.GrantTypes.RefreshToken.

    https://abp.io/support/questions/3842/Unable-to-authenticate-with-the-offlineaccess-scope-OpenIddict#answer-aa8dcd92-6f2a-67a8-2aad-3a06d6c2a9c0

    Please confirm this.

  • User Avatar
    0
    nabass created

    i found it i will try and tell you the result

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    The default project has an OpenIddictDataSeedContributor in the Domain project.

    https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs#L125

    Please add OpenIddictConstants.GrantTypes.RefreshToken to your appliction/client grand types.

  • User Avatar
    0
    nabass created

    finally it works thanks super man

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    : )

Made with ❤️ on ABP v9.1.0-preview. Updated on November 18, 2024, 05:54