2017-01-05 29 views
0

我想通過授權碼流從Token端點獲得「access_token」和「id_token」。但是,在postman上使用以下參數調用令牌端點時,出現「invalid_grant」錯誤。如何通過authorization_code流從IdentityServer4的TokenEndpoint獲取id_token?

POST /connect/token HTTP/1.1 
Host: localhost:2000 
Content-Type: application/x-www-form-urlencoded 
Cache-Control: no-cache 
Postman-Token: a8a29659-0ea3-e7dc-3bd6-6e6630a7370d 

client_id=client 
&client_secret=client 
&grant_type=authorization_code 
&username=admin 
&password=admin 
&scope=openid+profile 

客戶端配置:

new Client 
{ 
    ClientId = "client", 
    ClientSecrets = 
    { 
    new Secret("client".Sha256()) 
    }, 
    AllowedGrantTypes = new List<string> { OidcConstants.GrantTypes.AuthorizationCode }, 
    AllowedScopes = { 
    StandardScopes.OpenId.Name, 
    StandardScopes.Profile.Name, 
    } 
} 

什麼是錯誤的,我的客戶配置部分?並且,我如何向Token Endpoint發送成功的發佈請求?

回答

2

授權碼授權類型要求在令牌請求期間發送code參數(請參閱RFC6749 section 4.1.3)。

此代碼由授權服務器在資源所有者授權客戶端後頒發(請參閱RFC6749 section 4.1.2)。

相關問題