我创建了一个 Twitter 应用程序,我需要我的 Android 应用程序的用户授权其使用。我现在可以在浏览器中调用 Twitter 应用程序页面并成功授权。但是,回调似乎不起作用,我最终在浏览器中收到确认消息和 PIN,但我的 Android Activity 从未被调用(未触发 onResume)。 这是我的东西
- 推特网址:http://twitter.com/oauth/authorize?oauth_token=actualtokenhere&oauth_callback=myapp:///
在我的 Activity 定义中我有这个 intent-filter
<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="myapp" /> </intent-filter>
正如我所说 - 我得到确认但没有重定向,因此 Android 应用程序永远不会回调
最佳答案
好吧,事实证明我的配置没有任何问题。我的推特应用程序的“应用程序类型”设置错误 如果您遇到此问题 - 转到您在 Twitter 上的应用程序编辑 View 并检查“应用程序类型”的“浏览器”选项,然后如果身份验证成功,浏览器将重定向到回调 URL。现在 - 我不能使用 Android 风格的回调 URL (myapp://twitt),因为它不会通过表单验证。但事实证明——您可以在那里输入任何有效的 URL,并在您的代码中提供实际的回调 URL
关于android - Android 上的 oauth_callback,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1121329/