Android login in my app with google credentials
HI I'm developing an application in wich I want to permit the user to login to my server with his Google account without asking him the credentials because I know that are saved into the AccountManager class. The problem is that I don't know how to autenticate the user because the account ID is just stored in Google's server, so Where can I find an ID for the account and how can I use it to autenticate user? I'd like to follow these steps: user choose one of the stored account, I get an id, send it from the terminal to the server, and I answere that "he trust" this user, after this I save this id in my server and request an auth token to Google just to use it between my server and the application on android device.
Is this what you want?
List<String> googleAccounts = new ArrayList<String>();
Account[] accounts = AccountManager.get(this).getAccounts();
for (Account account : accounts) {
if (account.type.equals("com.google")) {
googleAccounts.add(account.name);
}
}
You can see a more detailed example in the code of the ChromeToPhone app open-sourced by Google: http://www.google.com/codesearch/p?hl=en#JWblrwroAxw/trunk/android/src/com/google/android/apps/chrometophone/MainActivity.java&l=311
链接地址: http://www.djcxy.com/p/49760.html上一篇: 多个命令和参数