2015-12-19 50 views
2

是否有人使用过Firebase和Google登录演示?FireBase Android登录演示不工作

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

我给它一个尝试,它编译就好了,但是当我按下按钮,在谷歌的标志,我选择我的个人资料,回调,我得到onActivityResult result.isSuccess假

@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"); 
    } 
} 

我是否需要对Google的控制台API与此创建一个项目:为结果回电下面

/* ************************************* 
*    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(); 

开始活动配置文件到这个项目为了这个工作?

回答

0

昨天我遇到了同样的问题。这个例子似乎已经过时了。使用提供的代码找不到解决方案。但有一种更直观的方式,需要更少的代码在官方文档中可以找到here.