我的应用程序中一个相当重要的部分是用户可以使用Google帐户登录 . 对于Play商店中的应用版本,我已经在使用 AccountManager
和Google Play服务 . 这个问题我安装了GPS(比如点燃器) .
我的一般想法是使用回调URL(在AndroidManifest中处理)弹出用户的默认Web浏览器,这样我就可以从那里获取oauth令牌:
public void requestTokenFallback(){
Uri.Builder builder = new Uri.Builder().scheme("https")
.authority("accounts.google.com")
.appendPath("o")
.appendPath("oauth2")
.appendPath("auth")
.appendQueryParameter("response_type", "token")
.appendQueryParameter("client_id", CLIENTID)
.appendQueryParameter("scope", SCOPE)
.appendQueryParameter("redirect_uri", "myapp-oauth");
Intent browserIntent = new Intent(Intent.ACTION_VIEW, builder.build());
activity.startActivity(browserIntent);
}
如果我将 response_type
设置为 "code"
,它允许我登录并给我一个令牌来复制和粘贴 . 如果我将其设置为 "token"
并使用 redirect_uri
urn:ietf:wg:oauth:2.0:oob
(因为在Google API控制台中为's what'),我会收到一条消息"redirect_uri not supported for response_type=token: urn:ietf:wg:oauth:2.0:oob"
我想知道如何在Google API控制台端配置此项以允许我将 myapp-oauth://access_token:XXXXXXXXX
设置为OAuth流重定向到的地址 .
有任何想法吗?
1 回答
查看我的帖子了解详情 . https://plus.google.com/+NaveenAgarwal/posts/AztHNnQh7w6
客户端可以使用以下任一自定义方案:com.example.myapp:/ oauth2Callback com.googleusercontent.apps.1234-abc:/ oauth2callback