Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓谷歌&x2B;登录-唯一ID_Android_Login_Google Plus_Unique - Fatal编程技术网

Android 安卓谷歌&x2B;登录-唯一ID

Android 安卓谷歌&x2B;登录-唯一ID,android,login,google-plus,unique,Android,Login,Google Plus,Unique,我尝试在我的应用程序上进行谷歌登录 而且它非常有效 但我想得到一个字符串或数字,是唯一的用户和应用程序。这样我就可以在我自己的服务器上授权了 我的实际做法是: 我要连接到谷歌 谷歌向android发送登录信息 Android将登录状态发送到我的服务器 但在最后一步,我需要得到一个唯一的值,比如一个数字或字符串 感谢您的idee具有一个唯一的值,键为id。此值特定于Google帐户,永远不会更改。如果您使用电子邮件范围对用户进行身份验证,则配置文件还将包含帐户的类型的用户电子邮件地址。这有助于

我尝试在我的应用程序上进行谷歌登录

而且它非常有效

但我想得到一个字符串或数字,是唯一的用户和应用程序。这样我就可以在我自己的服务器上授权了

我的实际做法是:

  • 我要连接到谷歌
  • 谷歌向android发送登录信息
  • Android将登录状态发送到我的服务器
但在最后一步,我需要得到一个唯一的值,比如一个数字或字符串

感谢您的idee具有一个唯一的值,键为
id
。此值特定于Google帐户,永远不会更改。如果您使用
电子邮件
范围对用户进行身份验证,则配置文件还将包含
帐户
类型
的用户电子邮件地址。这有助于将Google+配置文件与现有的身份验证系统或数据库相关联


要获取此信息,您必须使用
me
userId
向发出请求,并作为当前用户进行身份验证

您还可以尝试使用当前登录的人,如:

Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);

System.out.println("ID:\t" + currentPerson.getId());
System.out.println("Display Name:\t" + currentPerson.getDisplayName());
System.out.println("Image URL:\t" + currentPerson.getImage().getUrl());
System.out.println("Profile URL:\t" + currentPerson.getUrl());
在此之前,必须初始化
mGoogleApiClient

// [START create_google_api_client]
// Build GoogleApiClient with access to basic profile
mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(Plus.API)
        .addScope(new Scope(Scopes.PROFILE))
        .addScope(new Scope(Scopes.EMAIL))
        .build();
// [END create_google_api_client]


谢谢。

可能与否重复,我没有从设备中搜索唯一的ID。我搜索一个从谷歌+登录返回!好吧,但是这个应用程序的唯一id不像facebook id那样存在,这是每个人和应用程序的唯一id?!此id与Facebook不同,所有应用程序都会看到相同的id。