oauth_callback在Android [英] oauth_callback on Android

查看:157
本文介绍了oauth_callback在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Twitter的应用程序,我需要我的Andr​​oid应用程序,授权其使用的用户。我在的地步,我可以调用Twitter的应用程序页面在浏览器和成功授权。然而,回调似乎没有工作,我结束了在浏览器中的确认信息和PIN但我Android的活动永远不会被调用(onResume不触发)。 下面是我的

  1. 在微博网址:<一href="http://twitter.com/oauth/authorize?oauth_token=actualtokenhere&oauth_callback=myapp:///">http://twitter.com/oauth/authorize?oauth_token=actualtokenhere&oauth_callback=myapp:///
  2. 在我的活动定义我有这个意图过滤器

     &LT;意向滤光器&gt;
    &lt;作用机器人:名称=android.intent.action.VIEW/&GT;
    &LT;类机器人:名称=android.intent.category.DEFAULT/&GT;
    &LT;类机器人:名称=android.intent.category.BROWSABLE/&GT;
    &lt;数据机器人:计划=MyApp的/&GT;
        &所述; /意图滤光器&gt;
     

  3. 正如我所说 - 我得到确认,但不是重定向使Android应用程序是从来没有叫回来

解决方案

好了,竟然没有什么错我的配置。我的Twitter的应用程序根本就错误的设置为应用型 如果你有这样的问题 - 去在Twitter上你的应用程序编辑视图,并选中浏览器选项为应用程序类型,那么,如果认证成功的浏览器重定向到回调URL。现在 - 我不能使用Android的风格的回调URL(的myapp:// twitt),因为这不会通过表单验证。但实际上 - 你可以输入任何有效的URL出现在你的code提供了实际工作的回调URL

I created a Twitter app I need user of my Android application to authorize its use. I'm at the point where I can call Twitter app page in the browser and successfully authorize. However, the callback seem not to be working, I end up with the confirmation message and PIN in the browser but my Android activity is never called (onResume is not triggered). Here's what I have

  1. Twitter URL: http://twitter.com/oauth/authorize?oauth_token=actualtokenhere&oauth_callback=myapp:///
  2. In my activity definition I have this 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>
    

  3. As I stated - I get confirmation but not redirect so the Android app is never called back

解决方案

Well, turned out there was nothing wrong with my configuration. My twitter app simply had wrong setting for the "Application Type" If you have this problem - go to your app edit view on Twitter and check "browser" option for the "Application Type", then if authentication succeeds browser redirects to the callback URL. Now - I couldn't use Android-style callback URL (myapp://twitt) since that would not pass form validation. But turned out - you can enter anything that is valid URL there and provide the actuall callback URL in your code

这篇关于oauth_callback在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆