Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.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 使用Google登录时获取配置文件数据为空_Android_Google Play Services_Google Plus_Google Authentication - Fatal编程技术网

Android 使用Google登录时获取配置文件数据为空

Android 使用Google登录时获取配置文件数据为空,android,google-play-services,google-plus,google-authentication,Android,Google Play Services,Google Plus,Google Authentication,我集成了“谷歌登录”。代码在这里 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .requestProfile() .build(); mGoogleApiClient = new GoogleApiClient

我集成了“谷歌登录”。代码在这里

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .requestProfile()
                .build();
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .enableAutoManage(this,this)
                .build();
        mGoogleApiClient.connect();
        final Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
        startActivityForResult(signInIntent, RC_SIGN_IN);



 public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == RC_SIGN_IN) {
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            if (result.isSuccess()) {
                GoogleSignInAccount acct = result.getSignInAccount();
                String tokenId = acct.getIdToken();
                name = acct.getDisplayName();
                String personGivenName = acct.getGivenName();
                String personFamilyName = acct.getFamilyName();
                email = acct.getEmail();
                social_id = acct.getId();
                social_image = String.valueOf(acct.getPhotoUrl());
                Log.w("googleres", name + "," + personGivenName + "," + personFamilyName + "," + email + "," + social_id + "," + social_image);
            } else {
                Toast.makeText(this, "failed to login with google", Toast.LENGTH_SHORT).show();

            }
        }
    }
当我第一次使用新帐户登录时,我在日志中收到此响应

W/googleres: null,null,null,test@gmail.com,123456669985545,null
登录时,名称和显示图片变为空


第二次完美地获取所有数据

你说的第二次是什么意思?你注销,然后重新登录?@cricket_007是的,当我第二次登录时。你可能想检查这个讨论了如何正确配置谷歌登录。此外,启动登录流,其中intent提示用户选择要登录的Google帐户,然后检查作用域。如给定链接中所述,如果您请求的范围超出了profile、email和openid,系统还会提示用户授予对请求的资源的访问权。@Teyam,正如您在我正确配置的代码中所看到的那样。如果有任何配置问题,那么它不应该再次工作。你有什么解决方案吗?你说的第二次是什么意思?你注销,然后重新登录?@cricket_007是的,当我第二次登录时。你可能想检查这个讨论了如何正确配置谷歌登录。此外,启动登录流,其中intent提示用户选择要登录的Google帐户,然后检查作用域。如给定链接中所述,如果您请求的范围超出了profile、email和openid,系统还会提示用户授予对请求的资源的访问权。@Teyam,正如您在我正确配置的代码中所看到的那样。如果有任何配置问题,那么它不应该再次工作。您有任何解决方案吗?