首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GoogleSignInAccount account = task.getResult(ApiException.class);

GoogleSignInAccount account = task.getResult(ApiException.class);
EN

Stack Overflow用户
提问于 2019-07-19 01:25:25
回答 1查看 574关注 0票数 0

我正在开发一个使用firebase的google sign in的登录系统,我已经做了文档中提到的一切,我仍然无法登录。我猜在try and catch块中有问题。代码在此行停止运行,并在catch块中结束。

代码语言:javascript
复制
GoogleSignInAccount account = task.getResult(ApiException.class);

 public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        if (requestCode == RC_SIGN_IN) {
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);

            try {
                // Google Sign In was successful, authenticate with Firebase
                GoogleSignInAccount account = task.getResult(ApiException.class);
                progress.show();
                firebaseAuthWithGoogle(account);

            } catch (ApiException e) {

                // Google Sign In failed, update UI appropriately
                //  Log.w(TAG, "Google sign in failed", e);
                Toast.makeText(this, "Failed Sign in", Toast.LENGTH_SHORT);
                // ...
            }
        }
    }
EN

回答 1

Stack Overflow用户

发布于 2019-07-19 02:05:31

我认为您在使用Firebase Gmail身份验证时错过了一些配置。我在下面提到了工作中的Github存储库。它将帮助你让你的代码正常工作。

Github存储库

Androchef Firebase Auth Login

提交Gmail身份验证提交

Google sign in Added

关于Firebase 身份验证的谷歌博客文章

Firebase Google Authentication – Example

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57099818

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档