仅当在流程中添加帐户时,Google登录才会将显示名称返回为空. [英] Google Signin returns display name as null only when Add account in the flow

查看:135
本文介绍了仅当在流程中添加帐户时,Google登录才会将显示名称返回为空.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我当前的项目中,我已经实现了google登录功能.登录时正在获取用户信息.在流程中,可以选择在Google对话框中添加帐户.当用户当时尝试添加帐户时,我可以正确接收电子邮件,但显示名称为null.

In my current project I have implemented google sign in feature. Am fetching user information when logged in. In the flow, there is option to Add Account in google dialog. When user trying to add account on that time I am getting the email properly but the display name as null.

这是用于登录Google的代码.

Here is the code which am using for sign in google.

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .requestProfile()
                .requestScopes(new Scope(Scopes.PLUS_ME))
                .requestScopes(new Scope(Scopes.PLUS_LOGIN))
                .build();

有人可以帮我解决这个问题吗?

Can anyone help me to resolve this?

推荐答案

从google dev控制台创建网络令牌,并在您的android应用中使用它. googleblog 上有很棒的指南那.如果您按照它说的话,那么我可以肯定,您的问题将得到解决.不久前我也遇到了这种情况,然后我跟随了他们,问题解决了.

Create web token from google dev console and use it in your android app. There is wonderful guideline at googleblog about that. If you go according to it then i am sure, your problem will be solved. It happened to me as well some time ago then i followed them and my problem was solved.

GoogleSignInOptions gso =
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
    .requestIdToken(serverClientId) // here you will pass the client server id that you created
    .requestEmail()
    .build();

我希望这会对您有所帮助.

I hope this will help you somehow.

这篇关于仅当在流程中添加帐户时,Google登录才会将显示名称返回为空.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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