【问题标题】:Android Google Oauth: not returing to application after granting accessAndroid Google Oauth:授予访问权限后不返回应用程序
【发布时间】:2012-06-09 04:12:56
【问题描述】:

我在使用 signpost 库在 Android 中实现 Oauth 时遇到问题。一切都很好,除了最后一部分应该在授予访问权限后返回到应用程序本身。

以下是我在清单中的活动回调声明:

<activity android:name="ro.locationsApp.android.login.LoginScreenActivity" 
        android:screenOrientation="portrait"
        android:launchMode="singleTask">
        <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="http" android:host="myCallbackHost"/>
        </intent-filter>
    </activity>

我通过这样的代码传递回调 URL:

new OAuthHelper("mySite", "secret", 
        "https://www.googleapis.com/auth/userinfo.profile", "http://myCallbackHost");

myCallbackHost 是一个真实的功能链接(它也用于网站身份验证后的回调 - 现在我也想要移动设备)。

问题是我的 android 应用程序在此之后没有被调用。我也试过了

<data android:scheme="customScheme"/>

new OAuthHelper("mySite", "secret", 
    "https://www.googleapis.com/auth/userinfo.profile", "customScheme:///");   

但没有成功。

谢谢,

亚历克斯。

【问题讨论】:

    标签: android oauth callback android-manifest oauth-2.0


    【解决方案1】:

    用其他东西改变 http 是可行的。

    这是我的清单现在的样子:

    <activity android:name="ro.locationsApp.android.login.LoginScreenActivity" 
        android:screenOrientation="portrait"
        android:launchMode="singleTask">
        <intent-filter>
            <category android:name="android.intent.category.LUNCHER" />
        </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="alex" android:host="me"/>
        </intent-filter>
    </activity>
    

    和代码:

    new OAuthHelper("mySite", "secret", 
    "https://www.googleapis.com/auth/userinfo.profile", "alex://me"); 
    

    像魅力一样工作。

    【讨论】:

    • 你在android ICS中检查过同样的情况
    • 是的,在索尼爱立信 Xperia Arc S 上,安装了 ICS 并且可以正常工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-16
    • 2012-04-29
    • 2012-05-15
    • 2012-09-09
    相关资源
    最近更新 更多