DotNetOpenAuth를 사용하여 OAuth 서비스 공급자를 구축 중이며이를 테스트하기 위해 간단히 일반 HTTP 끝점을 호출하도록 샘플 wcf 소비자를 수정했습니다. 토큰 요청은 잘 작동하지만 보호 된 리소스에 대한 액세스를 요청할 때, 나는 다음과 같은 프로토콜 execption 수 :DotNetOpenAuth 소비자가 버전 1.0a를 준수하지 않는 이유는 무엇입니까?
Error while performing basic validation of AuthorizedTokenRequest with these message parts:
oauth_token: pgzjBIs0pKCeDIcaIinyrV5Jhi0=
oauth_consumer_key: sampleconsumer
oauth_nonce: TM0Rc8kg
oauth_signature_method: HMAC-SHA1
oauth_signature: zmpxK5c69n1VzTEEcrnnd4e+qYI=
oauth_version: 1.0
oauth_timestamp: 1305067751
: 내 서비스 제공에 로그 출력을 볼 때
The following required parameters were missing from the DotNetOpenAuth.OAuth.Messages.AuthorizedTokenRequest message: oauth_verifier
내가이 참조
소비자를 만들 때 ProtocolVersion.V10a를 지정 했더라도 oauth_version : 1.0을 확인하십시오. (이 샘플 코드에서 직접입니다) 여기
Expected message DotNetOpenAuth.OAuth.Messages.AccessProtectedResourceRequest but received DotNetOpenAuth.OAuth.Messages.AuthorizedTokenRequest instead.
토큰을 얻을 수있는 소비자의 코드입니다 : 내가 양쪽에 ProtocolVersion.V10를 지정하는 경우
나는이 예외가
WebConsumer consumer = this.CreateConsumer();
UriBuilder callback = new UriBuilder(Request.Url);
callback.Query = null;
string[] scopes = (from item in this.scopeList.Items.OfType<ListItem>()
where item.Selected
select item.Value).ToArray();
string scope = string.Join("|", scopes);
var requestParams = new Dictionary<string, string> { { "scope", scope } };
var response = consumer.PrepareRequestUserAuthorization(callback.Uri, requestParams, null);
consumer.Channel.Send(response);
내 소비자 코드가 실패했습니다 :
var accessToken = Session["WcfAccessToken"] as string;
var consumer = CreateConsumer();
var serviceEndpoint = new MessageReceivingEndpoint("https://mymachine/test/getUserName", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest);
var httpRequest = consumer.PrepareAuthorizedRequest(serviceEndpoint, accessToken);
var httpResponse = httpRequest.GetResponse();
서비스 제공 업체에서 난 serv iceProvider.ReadProtectedResourceAuthorization(); 위에서 언급 한 예외로 인해 실패합니다.
내가 잘못하고있는 아이디어가 있습니까?
실제로 토큰을 얻는 소비자에게 소스 코드를 포함하도록 질문 할 수 있습니까? –
DotNetOpenAuth와 함께 제공되는 샘플에서 OAuthConsumer SampleWcf.aspx 페이지를 사용하고 있다는 질문에 언급 한 바와 같이 get authorization에 대한 호출을 추가했습니다. –