我正在尝试请求身份验证令牌:
I'm trying to request an authentication token:
public static void RequestAuthorization(WebConsumer consumer) { var extraParams = new Dictionary<string, string> { { "oauth_token", string.Empty}, { "oauth_callback", "www.ihighfive/" }, }; var req = consumer.PrepareRequestUserAuthorization(callback, extraParams, null); consumer.Channel.Send(req); }问题是,当我运行.PrepareRequestUserAuthorization()时,出现以下错误
Problem is, when I run .PrepareRequestUserAuthorization() I get the following error
预期的IProtocolMessage消息,但未收到可识别的消息。
Expected IProtocolMessage message but received no recognizable message.
用Fiddler检查请求/响应,我可以看到响应返回(混淆值):
Inspecting the request/response with Fiddler, I can see that the response returns(values obfusticated):
{ "oauth_token" : "this-is-the-oauth-token", "oauth_token_secret" : "this-is-the-oauth-secret-token", "oauth_callback_confirmed" : true, "urlToSendUserTo" : "blah.blah/api/OAuthAuthorizeToken.aspx?oauth_token=token-value-is-really-long"}对我来说,这似乎是一个不错的选择。如果我访问urlToSendUserTo,它将起作用,然后将我传递到我的初始回调URL。因此,我想DNOA在解析响应时遇到问题,但我看不出为什么。
To me, this appears to be a good response. If I visit the urlToSendUserTo, it works, and then passes me through to my initial callback url. So I guess DNOA is having problems parsing the response, but I can't see why.
推荐答案服务器使用的协议是什么?它不是OAuth 1.0,而是您在DotNetOpenAuth中使用OAuth 1.0类。 OAuth 1.0要求,该响应位于 application / x中-www-form-urlencoded 格式,但在您的响应摘要中,它显然是JSON。
What protocol is the server using? It's not OAuth 1.0 but you're using OAuth 1.0 classes in DotNetOpenAuth. OAuth 1.0 mandates that the response be in application/x-www-form-urlencoded format but in your snippet of the response it's clearly in JSON instead.
此外,我从未见过 urlToSendUserTo 参数在任何规范中,我不知道您为什么要发送空的 oauth_token 作为额外参数
Also, I've never seen the urlToSendUserTo parameter in any spec, and I don't know why you're sending an empty oauth_token as an extra parameter in the request.
您和/或服务器使用的语言似乎完全不同。
It seems like you and/or the server are speaking very different languages.
更多推荐
DotNetOpenAuth预期的IProtocolMessage消息
发布评论