Open Closed

How to get JWT #7570


User avatar
0
fgao@primarypartnercare.com created
  • ABP Framework version: v8.2.0
  • UI Type: Blazor WASM
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I created an application with abp template. The swagger works fine. Now I need to test its APIs from Postman. For example, through GET https://my-company.com/api/identity/roles/all. (This API does not require parameters.) It does not return a list of roles, instead, it outputs a html page. It looks correct, because I haven't been authenticated.

Usually, I first need to GET a JWT bear token with my credential and then send http request to other APIs with the token in header. However, I couldn't find the endpoint on swagger to get JWT. I wonder if abp identity server supports JWT Auth? If so, how do I get the bear token? If not, how do I choose Authorization type from Postman?

Thanks


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

    Hi,

    /connect/token endpoint is used to get access_token.

    For example:

  • User Avatar
    0
    fgao@primarypartnercare.com created

    I tested this, but always get "error": "invalid_scope". I tried to use my email address as scope-Value. Still same error. Can you provide a sample value?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    please share some screenshots

  • User Avatar
    0
    fgao@primarypartnercare.com created

  • User Avatar
    0
    fgao@primarypartnercare.com created

    I also tried client_id and scope from swagger authorize page. This time, the error changed as "error": "invalid_client"

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    it's wrong.

    should be client_id not client_Id

    if you got invalid_granttype, you can edit the application in the application management page to enable password granttype

  • User Avatar
    0
    fgao@primarypartnercare.com created

    Just tried changing that. The new error is "error": "unauthorized_client",

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    you can edit the application in the application management page to enable password granttype

  • User Avatar
    0
    fgao@primarypartnercare.com created

    Where is the application management page? In interface or in code? I couldn't fine neither. Can you show a screenshot?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

  • User Avatar
    0
    fgao@primarypartnercare.com created

    Got it. Works great.

    Thank you!

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    great

Made with ❤️ on ABP v9.1.0-preview. Updated on November 19, 2024, 12:56