Search code examples
postmanasp.net-identityidentityserver4

Is it possible to make authentication in identityserver4 only available via REST calls?


I'm quite new with identityserver4 so correct me if I say something wrong. I have set up identityserver4 together with ASP Identity for usermanagement and protected my API with it, however I don't know how to get an access token without having to be redirected to the login page. I'm using postman to get an access token via the authorization tab using the following details:

enter image description here

  new Client
  {
     ClientId = "postman-api",
     ClientName = "Postman Test Client",
     ClientSecrets = { new Secret("PostmanIsASecret".Sha256()) },
     AllowedGrantTypes = GrantTypes.Implicit,
     AllowAccessTokensViaBrowser = true,
     RequireConsent = false,
     RedirectUris = { "https://www.getpostman.com/oauth2/callback"},
     PostLogoutRedirectUris = { "https://www.getpostman.com" },
     AllowedCorsOrigins = { "https://www.getpostman.com" },
     EnableLocalLogin = false,
     RequirePkce = false,
     AllowedScopes =
     {
        IdentityServerConstants.StandardScopes.OpenId,
        IdentityServerConstants.StandardScopes.Profile,
        IdentityServerConstants.StandardScopes.Email,
        "jumsum.api"
     }
}

I just want to login and get an access token without having to be redirected all the time. In the console I'm getting this:

IdentityServer4.ResponseHandling.AuthorizeInteractionResponseGenerator: Information: Showing login: User is not authenticated

I just want to pass a username and password via the http request body and get an access token back. What am I doing wrong?


Solution

  • You could add a client that accepts the client credentials flow and using this flow you can get an access token using just a username and password. This is a flow for machine-to-machine communication where no human user is involved.

    Read more about that here