2016-05-09 5 views
2

ValidateClientAuthentication関数でクライアントIDを検証しようとしています。私はgrant_type =パスワードフローを使用しています。ここでは、auth token request bodyにclient_idを渡しています。ValidateClientAuthenticationでclient_idは常にnullです

Content-Type: application/x-www-form-urlencoded 
grant_type=password&[email protected]&password=pwduser1&client_id=B36B-07DEAC802BEA 

クライアントIDを検証するためにClientIdにアクセスしようとすると、常にnullになります。

if (context.ClientId != null) 
    { 
     //Set the client who initiated request is valid 
     context.Validated(); 
    } 
    else 
    { 
     //reject access to application 
     context.Rejected(); 
     context.SetError("Invalid client_id", "Client_id must present in the request header"); 
    } 

grant_type = passwordの場合、クライアントIDをトークンエンドポイントに渡す正しい方法は何ですか?

あなたのお手伝いをお待ちしております。あなたのclient_idは、フォームのparamとして渡された場合

答えて

10

、あなたのclient_idAuthorizationヘッダーとして渡された場合、あなたは一度context.TryGetBasicCredentials(out clientId, out clientSecret);

を行うことによってそれを得ることができcontext.TryGetFormCredentials(out clientId, out clientSecret);

を行うことによってそれを取得する必要がありますcontext.Validated(clientId)を入力してcontext.ClientIdプロパティを設定します。完了するまでこのプロパティは常にnullになります。context.Validated()

関連する問題