简体   繁体   English

尝试使用Windows Phone 8 / 8.1授权应用程序时无法授权Twitter

[英]failed to authorize twitter when trying to authorize app with windows phone 8/8.1

I've got a windows phone 8/8.1 app which contains a page with an embedded web browser on it. 我有一个Windows Phone 8 / 8.1应用程序,其中包含一个带有嵌入式Web浏览器的页面。 I build a list of articles extracting information from the website and all of this works fine but note that I only use this web browser to display an article when a user has clicked on the item in my list. 我建立了一个从网站提取信息的文章列表,所有这些工作正常,但是请注意,只有当用户单击列表中的项目时,我才使用此Web浏览器显示文章。

The article in question provides a button to allow user to leave comments via twitter. 该文章提供了一个按钮,允许用户通过Twitter发表评论。 At the bottom of each article there is a "Twitter Log in" button. 每篇文章的底部都有一个“ Twitter登录”按钮。 When I click on it, it brings me to the authorizing page and it displays the news website as the app I want to authorize. 当我单击它时,它带我到授权页面,并且将新闻网站显示为我要授权的应用程序。

After entering my twitter credential and clicking on the "Authorize App", I get the following error: 输入我的Twitter凭据并单击“授权应用程序”后,出现以下错误:

Exception of type 'Microsoft.Phone.Controls.WebBrowserNavigationException' was thrown.

Then a Twitter webpage gets displayed display the following: 然后将显示一个Twitter网页,其中显示以下内容:

There is no request token for this page. That's a special key we need from applications asking you to use your Twitter account. Please go back to the site or application that sent you here and try again. It's probably just a mistake.

It definitely authenticated me as I can see my Twitter account picture but it failed to authorize the app. 当我看到我的Twitter帐户图片时,它肯定对我进行了身份验证,但未授权该应用程序。

I understand that my app is not the original website as it is a wp8/8.1 app but what I'm calling in the web browser is the page that contains all the original code from the news website and therefore you would assume everything would work as if I was calling the website directly from a browser. 我了解我的应用程序不是原始网站,因为它是wp8 / 8.1应用程序,但是我在网络浏览器中调用的是包含新闻网站所有原始代码的页面,因此,您会假设一切正常如果我是直接从浏览器调用网站。

If I call the website from the browser that comes with wp8/8.1, it works as expected!! 如果我从wp8 / 8.1附带的浏览器中调用该网站,则它可以正常工作!! Strangely enough they have the same functionality but using facebook and this works as expected. 奇怪的是,它们具有相同的功能,但使用的是Facebook,并且按预期工作。

I've had a look at html the "twitter authorized page" when called from my phone and when called directly from my web browser on my laptop and while I can clearly see the form contains an hidden field for authenticity_token with a value and a oauth_token with another value, they do differ. 当我从手机上调用和直接从笔记本电脑上的Web浏览器调用时,我已经查看了html的“ twitter授权页面”,虽然我可以清楚地看到该表单包含一个authenticity_token的隐藏字段,其中包含一个值和一个oauth_token与另一个值,他们确实有所不同。

I don't know if they're suppose to be identical but as I said, I don't understand why this wouldn't work as when I display the article in the embedded web browser, you'd assume that everything else that goes on after this would behave as it would in a regular web browser and when this 'authorize app' button is clicked, you'd assume that all values would be passed as normal and the app would get authorized but nope!! 我不知道它们是否应该相同,但是正如我说的那样,我不明白为什么这样做不起作用,因为当我在嵌入式Web浏览器中显示文章时,您会认为其他所有内容之后,其行为将与常规网络浏览器中的行为相同,并且当单击此“授权应用程序”按钮时,您将假定所有值都将按常规方式传递,并且该应用程序将获得授权,但不会!

Any suggestions on how I could possible resolve this problem? 关于如何解决此问题的任何建议?

Thanks. 谢谢。

I can't really tell what's going on, but it looks like you would have to implement Twitter OAuth. 我无法真正判断发生了什么,但是您似乎必须实现Twitter OAuth。 Luckily for you there is already a library that can do that - https://github.com/konradbartecki/TwitterAutherino 幸运的是,已经有一个图书馆可以做到这一点-https://github.com/konradbartecki/TwitterAutherino

I am the author of this library, so let me know if you need some support or non-existent features. 我是该库的作者,所以让我知道您是否需要一些支持或不存在的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM