How to call Identity Server 4 with Postman for login
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 :
- Enter your api's URL .
In
Authorization
Type, there is a dropdownlist, selectOAuth2
: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 .Click on
Request Token
, you’ll see a new token added with the name ofTokenName
Finally, make sure you add the token to the header then click onUse Token
. Token will available when sending request as authorization header :
I wrote an entire step by step tutorial on how to make this happen, because the answers to this topic were'nt good enough for me.
What is different to the other responses, is how to get and store the bearer token automatically and use it for testing without having to do anything else. Perfect for integration testing your controller classes.
https://medium.com/@rotter.axel/automatically-sign-in-to-identity-server-4-with-postman-and-test-net-core-controller-methods-bc5d8feb199e