Author : MD TAREQ HASSAN | Updated : 2020/06/19
Identity Server Project
- Create an empty solution
- View > Other Windows > Package Manager Console
Commands
dotnet new -i identityserver4.templates
dotnet new is4inmem
Testing with Postman
- Download and install postman
- We are gonna get OAuth 2.0 Access Token (code flow + pkce) from IdentityServer4 (running locally)
- We are gonna use scope = ‘openid profile’ (IdentityServer4 is also OIDC provider)
Run IdentityServer4 locally
Required information for Postman to get Access Token
Open Config.cs
& add a client for Postman
// ... ... ...
public static IEnumerable<Client> Clients =>
new Client[]
{
// ... ... ...
new Client
{
ClientId = "postman",
ClientName = "Postman Client",
AllowedGrantTypes = GrantTypes.CodeAndClientCredentials,
RequirePkce = false,
ClientSecrets = { new Secret("hovermind.postman".Sha256()) },
RedirectUris = { "http://localhost:5003/signin-oidc" },
FrontChannelLogoutUri = "http://localhost:5003/signout-oidc",
PostLogoutRedirectUris = { "http://localhost:5003/signout-callback-oidc" },
AllowOfflineAccess = true,
AllowedScopes = { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Profile }
}
// ... ... ...
};
Discovery document
- Install JSON Formatter chrome extension
- Goto: https://localhost:5001/.well-known/openid-configuration
- get ‘Auth URL’ & ‘Access Token URL’
Quickstart/TestUsers.cs
- there are 2 users
- use Username & Password of alice (or bob)
Other information
Scope: openid profile
State: anything
(i.e.State: foobarbaz
)
Example
Callback URL: http://localhost:5003/signin-oidc
Auth URL: https://localhost:5001/connect/authorize
Access Token URL: https://localhost:5001/connect/token
Client ID: postman
Client Secret: hovermind.postman
Scope: openid profile
State: foobarbaz
Username = "alice"
Password = "alice"
Getting access token (code flow + pkce) using Postman
See troubleshooting and solve issues first