1

我在使用路标库在 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:///");   

但没有成功。

谢谢,

亚历克斯。

4

1 回答 1

0

用其他东西改变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"); 

奇迹般有效。

于 2012-06-08T20:12:56.430 回答