How to call Identity Server 4 with Postman for login

前端 未结 2 2195
傲寒
傲寒 2021-02-02 17:19

I\'ve a solution in Visual Studio \'TourManagement\' which contains 2 projects of .Net core. One is IDP using Identity Server 4, second project is RESTful API of TourManagement

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-02 18:03

    The key point is getting access token for accessing tourmanagementapi using implicit flow in Postman for testing .

    The first thing is set AllowAccessTokensViaBrowser to true in client config in GetClients function , so that you can transmit access tokens via the browser channel,:

    new Client
    {
    .....
        AllowAccessTokensViaBrowser =true,
    .....
    }
    

    On Postman side , do the following :

    1. Enter your api's URL .
    2. In Authorization Type, there is a dropdownlist, select OAuth2 :

    3. After selecting it, you’ll notice a button that says Get Access Token, click on it and enter the following information (Based on your codes):

      Don't enter openid/profile as Scope since you are using Oauth2 in Postman .

    4. Click on Request Token, you’ll see a new token added with the name of TokenName Finally, make sure you add the token to the header then click on Use Token. Token will available when sending request as authorization header :

提交回复
热议问题