2017-06-06 158 views
0

我正在嘗試使用Google身份驗證獲取我的Firebase數據的書面許可。不過,雖然我相信我配置了大部分功能,但在嘗試連接到Google時無法正常工作,但我不確定接下來要設置的內容。AngularFire2 OAuth2與谷歌獲取Firebase授權錯誤

我的網頁上登錄功能:

import { AngularFireAuth } from 'angularfire2/auth'; 
import * as firebase from 'firebase/app'; 
... 
constructor(public navCtrl: NavController, public navParams: NavParams, public AFAuth: AngularFireAuth) { } 
... 
login() { 

    this.AFAuth.auth.signInWithRedirect(new firebase.auth.GoogleAuthProvider()) 
     .then(function(result) { 
      this.GoogleAccessToken = result.credential.accessToken;  // This gives you a Google Access Token. You can use it to access the Google API. 
      this.GoogleUser = result.user;       // The signed-in user info. 
      this.LoggedIn = true; 
      console.log('Logged In'); 
     }) 
     .catch(function(error) { 
      console.log('Error Logging In: ' + error) 
     } 
    ); 
} 

我總是收到此錯誤:

Error Logging In: Error: This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console. 

注意我的數據設置爲只讀,和我的應用程序正確地訪問所有的數據,所以我有正確的AngularFire Firebase連接字符串。

我還驗證Firebase.apiKey和Firebase.authDomain都與Google API Manager中的設置匹配。我的authDomain也在Browser key (auto created by Google Service)上以白名單HTTP referrers (web sites)列出。

我試過這個從我的本地端口被白名單(開發機器),並通過將代碼放在網站上測試它,也失敗了。

所有的參考文獻是http://xxxxx.domain.com,沒有www,因爲我們不能從www.domain.com訪問我們的應用程序。

要刪除參考設置作爲可能的問題,我已將參考過濾器更改爲無。但是,這會導致產生一個Error 401, deleted_client. The OAth client was deleted.

回答

0

您的瀏覽器API密鑰必須具有一些引用者限制。 在Google雲端控制檯中,轉到您正在使用的瀏覽器密鑰,通常會標記該密鑰(由Google服務自動創建),並將「密鑰限制」設置爲「無」。

+0

即使回到無,所以沒有限制,然後我得到一個錯誤401,deleted_client。 OAth客戶端已被刪除。「我已將此添加到我的原始問題中以幫助澄清。 –