登录Android应用程序与Gmail凭证凭证、应用程序、Android、Gmail

2023-09-08 00:06:44 作者:三岁半的小仙女

获得身份验证令牌如何使用它与谷歌的凭据登录后

After getting the auth Token how to use it to login with google credentials

 AccountManager am=AccountManager.get(this); 
 Account[] accounts= am.getAccountsByType("com.google");
 account=accounts[0];
 amf = am.getAuthToken(account,"com.google", true,  
        new AccountManagerCallback<Bundle>() {  
   public void run(AccountManagerFuture<Bundle> arg0) {  

                try {  
                    Bundle result;  
                    Intent i;  
                    String token;  

                    result = arg0.getResult();  
        if (result.containsKey(AccountManager.KEY_INTENT)) {  
                        i = (Intent)result.get(AccountManager.KEY_INTENT);  
                        System.out.println("INtect=="+i.toString());
                        if (i.toString().contains("GrantCredentialsPermissionActivity")) {  

                            cbt.startActivity(i);  
                            System.out.println("ssstttt");
                        } else {  
                            cbt.startActivity(i);
                            System.out.println("endddddd");
                        }  

                    } else {       
 token = (String)result.get(AccountManager.KEY_AUTHTOKEN);  

我已得到谷歌帐户生成的API密钥,但如果发送的authToken和API密钥,以便用户可以登录使用他的Gmail凭据

I have got the generated API key from google Account,but where to send the authToken and API key so that user can login using his gmail credentials

推荐答案

它不使用Gmail凭据建议,由于Google+和Gmail合并,你真正想要的,是能够通过Google+登录。这也将让你能够进行API调用。

It's not recommended using Gmail credentials, since Google+ and Gmail is merged, what you actually want, is to be able to login with Google+. This will also make you able to make API calls.

阅读更多实施的Google+登录,在您的应用程序这里

Read more implementing Google+ sign in, in your app here