2015-12-19 84 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.