OpenID的为需要签到Android应用 [英] OpenID for android apps that require SignIn

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

问题描述

我是谷歌的Andr​​oid平台上的一个新的开发者 - 我的HTC Desire上周抵达

I am a fresh developer on Googles Android Platform - my HTC Desire arrived last week.

现在我需要一种方法来登录到我的现有应用程序(Java中,码头上正在运行)。 服务器应用程序是使用开发的Spring Security 3.0.2

Now i need a way to sign in to my existing application (Java, currently running on jetty). The server Application is developed using spring security 3.0.2

在我的情况,我要支持以下内容: 如果用户建立了自己的Andr​​oid手机用Googlemail电子邮件/谷歌帐户(和大多数用户一样)我想用这个帐户凭据自动地在我的服务器上的应用程序日志。

In my case, i want to support the following: If a user has set up his Android phone with a googlemail/google-Account (and most users do) i want to use this account credentials to automagically log in to my server app.

有没有Android框架支持该用例? 还是有什么办法?

Is there any Android framework supporting that use-case? Or are there any alternatives?

我读:HTTP code.google.com国际机场/解-DE /原料药/帐号/文档/ OpenID.html

I read: http code.google.com intl/de-DE/apis/accounts/docs/OpenID.html

我们如何登录与谷歌AppEngine上的应用程序在这里描述:<一href="http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app">http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app

How we do sign in with an app on google AppEngine is described here: http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app

推荐答案

我想你想要的是使用的的AccountManager

I think what you want is to use AccountManager

要找出什么类型的谷歌帐户,使用类似:

To find out what type the google account is, use something like:

AuthenticatorDescription[] types = mAccountManager.getAuthenticatorTypes(); //
for (AuthenticatorDescription type : types) {
  Log.d("account types", type.type);
}

然后像做

AccountManager mAccountManager = AccountManager.get(context);
Account[] mAccounts = AccountManager.get(context).getAccountsByType("com.google");
// Choose which account to use if there are multiple google accounts registered, save to Account mAccount
AccountManagerFuture<options> response = mAccountManager.getAuthToken(mAccount, type, options, activity, mCallback, mHandler); // define callback and handler yourself for where to return

当用户达到mCallback在mHandler,登录过程就完成了。通常的谷歌登录对话将被使用,如果尚未登录到他/她的谷歌帐户的用户。

When the user reaches mCallback in your mHandler, the login process is done. The usual google login dialogue will be used if the user is not already logged in to his/her Google account.

尝试一下自己,让我知道,如果它帮助你!

Try it out for yourself and let me know if it helped you!

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

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