Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/396.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
Java 谷歌在重新登录时不要求输入密码_Java_Android_Rest_Google Drive Android Api - Fatal编程技术网

Java 谷歌在重新登录时不要求输入密码

Java 谷歌在重新登录时不要求输入密码,java,android,rest,google-drive-android-api,Java,Android,Rest,Google Drive Android Api,我正试图将我的应用程序生成的ZIP文件上传到用户的谷歌硬盘。 到目前为止,用户可以使用RESTAPI毫无问题地登录Google GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); mGoogleSignInCli

我正试图将我的应用程序生成的ZIP文件上传到用户的谷歌硬盘。 到目前为止,用户可以使用RESTAPI毫无问题地登录Google

        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();

        mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
        Intent signInIntent = mGoogleSignInClient.getSignInIntent();
        startActivityForResult(signInIntent, REQUEST_CODE_GOOGLE_SIGN_IN);
但我的应用程序并不是为一个用户设计的。 当下一个用户来生成自己的ZIP文件时,他可能希望使用自己的Google帐户登录并将文件上载到自己的Google驱动器。 因此,我还实现了注销代码

    private void signOut() {
        String currentGoogleAccountDisplayName = "";
        if(mGoogleSignInClient == null) {
            GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestEmail()
                    .build();

            mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
        }

        GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(mActivity.getApplicationContext());
        if(account != null) {
            currentGoogleAccountDisplayName = account.getDisplayName();
        }
        final String msg = "Revoke account \"" + currentGoogleAccountDisplayName + "\" access completed.";

        mGoogleSignInClient.revokeAccess()
                .addOnCompleteListener(this,
                        (@NonNull Task<Void> task) -> {
                            // Show sign-out message
                        });


    }

它们都不请求以后的用户再次提供身份验证

我还发现有人提到了一些答案

    GoogleApiClient.clearDefaultAccountAndReconnect(); 
但此API已被弃用。 在
谷歌签名
中没有类似
.requestPassword()
的东西

是否有适当的方法注销用户,并在用户每次尝试使用REST API重新登录时提示身份验证(即要求他输入密码)

这里有一个类似的问题(但没有答案)--

    mGoogleSignInClient.signOut();
    GoogleApiClient.clearDefaultAccountAndReconnect();