Google Signin returns display name as null only when Add account in the flow

偶尔善良 提交于 2019-12-22 08:59:11

问题


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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/42128245/google-signin-returns-display-name-as-null-only-when-add-account-in-the-flow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!