简体   繁体   English

FireBase Android登录演示无法正常运行

[英]FireBase Android SignIn Demo Not working

Has anyone used Firebase and Google sign in demo? 有没有人使用Firebase和Google登录演示?

https://github.com/firebase/firebase-login-demo-android/pull/21 https://github.com/firebase/firebase-login-demo-android/pull/21

I have given it a try and it compiles just fine but when I press on the Google sign in button, and I select my profile, the callback that I get onActivityResult result.isSuccess as false 我已经尝试了一下,并且可以正常编译,但是当我按下Google登录按钮,然后选择我的个人资料时,我将onActivityResult result.isSuccess设为false的回调

/* *************************************
*               GOOGLE                *
***************************************/

/* Load the Google login button */
mGoogleLoginButton = (SignInButton) findViewById(R.id.login_with_google);
mGoogleLoginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            startActivityForResult(signInIntent, RC_GOOGLE_LOGIN);
        }
    });

/* Setup the Google API object to allow Google logins */
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestEmail()
        .build();

mGoogleApiClient = new GoogleApiClient.Builder(this)
        .enableAutoManage(this, this)
        .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
        .build();

Start activity for result call back below: 开始活动,以便在下面返回结果:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_GOOGLE_LOGIN) {
        /* This was a request by the Google API */
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            GoogleSignInAccount acct = result.getSignInAccount();
            String emailAddress = acct.getEmail();
            getGoogleOAuthTokenAndLogin(emailAddress);
        }
    } else {
        Log.d(TAG, " Sign in Result is not success");
    }
}

Do I need to create a project for this on Googles Console API and the configuration file to this project in order for this to work? 我是否需要在Googles Console API上为此创建一个项目以及该项目的配置文件,然后才能正常工作?

I ran into the same issue yesterday. 昨天我遇到了同样的问题。 The example seems to be outdated. 这个例子似乎已经过时了。 I couldn't find a solution using the provided code. 使用所提供的代码找不到解决方案。 But there is a more intuitive way needing less code in the official documentation you can find here. 但是有一种更直观的方法,需要在此处找到的官方文档中的代码更少

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM