不建议使用Google Plus API。我如何从requestScopes(Scope(Scopes.PROFILE))获取性别和出生日期

Abhishek chaniyara

不建议使用Google Plus API。我如何从请求范围获得性别和出生日期。下面是我的代码:

val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken("xxxxxxxxx.apps.googleusercontent.com")
                .requestEmail()
                .requestProfile()
                .requestScopes(Scope(Scopes.PROFILE))
                .build()

   val mGoogleSignInClient = GoogleSignIn.getClient(this, gso)

从这个登录选项,我想要谷歌用户的性别和生日。

 public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
        super.onActivityResult(requestCode, resultCode, data)
        callbackManager.onActivityResult(requestCode, resultCode, data)

        if (requestCode == RC_SIGN_IN) {
            val result = GoogleSignIn.getSignedInAccountFromIntent(data)
            try {
                val account = result.getResult(ApiException::class.java)
                //Here I want gender and date of birth from google sign in option
            } catch (e: ApiException) {
                e.printStackTrace()
            }

        }
    }
索拉·维玛(Saurabh Verma)

由于不建议使用google plus api,因此我们必须将应用程序从google plus身份验证迁移到Google Auth。解决问题的方法如下。Google的People API将对您获取所需的详细信息链接有所帮助

https://www.googleapis.com/auth/userinfo.profile

https://www.googleapis.com/auth/contacts

https://www.googleapis.com/auth/contacts.readonly

https://www.googleapis.com/auth/userinfo.email

https://www.googleapis.com/auth/profile.agerange.read

https://www.googleapis.com/auth/profile.language.read

https://www.googleapis.com/auth/user.addresses.read

https://www.googleapis.com/auth/user.birthday.read

https://www.googleapis.com/auth/user.phonenumbers.read

https://www.googleapis.com/auth/user.emails.read

您需要确切要求您想要哪些字段。“性别”和“生日”字段可能对您来说最重要,但还有其他可用的字段。您将获得一个可能值的数组,每个值指示其来源。您可能需要源类型为“ PROFILE”,但是您当然可以评估其他类型。

因此,如果您发出请求

GET https://people.googleapis.com/v1/people/101852559274654726533?personFields=gender%2Cbirthdate&key={YOUR_API_KEY}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用Google OAuth API检索出生日期和婚姻状况

如何使用php在MySQL中插入出生日期?

如何通过使用Carbon datetime扩展名将laravel中的出生日期从数据库匹配到laravel中的当前月来获取数据?

如何使用Express-Validato验证出生日期?

如何使用Mongoose在Node JS中将此出生日期转换为年龄

如何使用NHibernate QueryOver计算给定出生日期的年龄

如何在Flutter中使用DateFormat选择出生日期?

如何使用三个选择框插入出生日期?

如何使用 Selenium 在 Discord 网站的“出生日期”部分中选择月份

使用出生日期计算年龄

如何使用Google电子表格为特定年份生成出生日期的随机数据?

我想在python中获取用户的出生日期

使用oracle sql获取当前年份的出生日期

Laravel 5:如何使用简单的出生日期中间件(在过滤器之前)?

我正在尝试添加检查约束以检查年龄和出生日期

如何根据出生日期和getDate()计算年龄(以年为单位)

如何在dbpedia中查询棒球运动员的全名和出生日期

硒 - Python | 使用标签的出生日期字段

使用PHP的出生日期至年龄范围

根据未使用JavaScript显示的出生日期

在Ruby on Rails中使用滑块输入出生日期

使用格式从出生日期计算年龄

不建议使用Google Play游戏服务和Google Drive API

如何通过熊猫的出生日期获得年龄栏?

如何为出生日期添加世纪前缀?

Google Plus:获取“我”

如何使用FirebaseAuth从Google供应商获取性别和生日?

如何过滤并返回出生日期年份介于 1960 年和 1965 年(含)之间的患者数组?

Meetup API,如何获取性别和生日