Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Identity server /connect/token is returning unauthorized client #1567

Closed
rahulmistry25425 opened this issue Sep 27, 2017 · 7 comments
Closed

Comments

@rahulmistry25425
Copy link

rahulmistry25425 commented Sep 27, 2017

I am using .net core 2.0 identity server 4 approach

I am trying to get access token from identity server using postman.

Postman post request

x-www-form-urlencode post

client_id:ASAP-Mobile
client_secret:ASAP@Mobile
response_type:code id_token
scope:openid profile aspa-api offline_access
grant_type:password

Client configuration


 new Client
                {
                    ClientId = "ASAP-Mobile",
                    ClientName = "ASAP Mobile Client",
                    AllowedGrantTypes = GrantTypes.Hybrid,                    
                    //Used to retrieve the access token on the back channel.
                    ClientSecrets =
                    {
                        new Secret("ASAP@Mobile".Sha256())
                    },
                    RedirectUris = { $"{clientsUrl["ASAPMobileUrl"]}" },
                    RequireConsent = false,
                    PostLogoutRedirectUris = { $"{clientsUrl["ASAPMobileUrl"]}/Account/Redirecting" },
                    AllowedCorsOrigins = { "http://asapmobile" },
                    AllowedScopes = new List<string>
                    {
                        IdentityServerConstants.StandardScopes.OpenId,
                        IdentityServerConstants.StandardScopes.Profile,
                        IdentityServerConstants.StandardScopes.OfflineAccess,
                        "asap-api",
                    },
                    //Allow requesting refresh tokens for long lived API access
                    AllowOfflineAccess = true
                },

``` Here is log

Start token request validation
dbug: IdentityServer4.Validation.TokenRequestValidator[0]
Start resource owner password token request validation
fail: IdentityServer4.Validation.TokenRequestValidator[0]
ASAP-Mobile not authorized for resource owner flow
fail: IdentityServer4.Validation.TokenRequestValidator[0]
{
"ClientId": "ASAP-Mobile",
"ClientName": "ASAP Mobile Client",
"GrantType": "password",
"Raw": {
"client_id": "ASAP-Mobile",
"client_secret": "REDACTED",
"response_type": "code id_token",
"scope": "openid profile aspa-api offline_access",
"grant_type": "password"
}
}

Here is Screenshot

image

@leastprivilege
Copy link
Member

You set the allowed grant type to be hybrid - but you are using the password grant type in postman. Hence the error.

@rahulmistry25425
Copy link
Author

rahulmistry25425 commented Sep 27, 2017

@leastprivilege available grant types are authorization_code, client_credentials, password, refresh_token
so what should i use in grant type for hybrid?

@GuerrillaCoder
Copy link

I have same issue, did you manage to resolve it?

@rahulmistry25425
Copy link
Author

@GuerrillaCoder make sure you are using AllowedGrantTypes = GrantTypes.ResourceOwnerPassword for client, and must be a same Scope as defined in your client scopes

@GuerrillaCoder
Copy link

@rahulmistry25425 Thanks. My issue was that and I had to make the callback URLS match my local callback url.

@vaarenyam
Copy link

vaarenyam commented Jul 30, 2018

I am facing the same issue of "unauthorized client". I ahave absolutely no clue in terms of what needs to be done to fix the issue. Can someone please help.

I have AllowedGrantTypes = implicit

image

I have the following configuration:

image

@lock
Copy link

lock bot commented Jan 13, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants