Ionic 离子- Firebase身份验证:此域未被授权对您的Firebase项目执行OAuth操作

3j86kqsm  于 2022-12-08  发布在  Ionic
关注(0)|答案(2)|浏览(105)

I am developing an Ionic App where I need to login via twitter. I developed this a few days ago and it worked fine but recently faced this error:
"Firebase: This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console. (auth/unauthorized-domain)".

signInWithRedirect() {
const auth = getAuth();
signInWithRedirect(auth, new TwitterAuthProvider())
  .then(() => {
    console.log(window);
    return getRedirectResult(auth);
  })
  .then((result) => {
    const credential = TwitterAuthProvider.credentialFromResult(result);

    // This gives you a Google Access Token.
    // You can use it to access the Google API.
    const token = credential.accessToken;

    // The signed-in user info.
    const user = result.user;
    this.user = user;
    // ...
  })
  .catch((error) => {
    // Handle Errors here.
    const errorCode = error.code;
    const errorMessage = error.message;
    this.error = { errorCode, errorMessage };
  });

}
This is my package.json file.

"@angular/common": "~12.1.1",
"@angular/compiler": "~12.1.1",
"@angular/core": "~12.1.1",
"@angular/fire": "^7.0.3",
"@angular/forms": "~12.1.1",
"@angular/platform-browser": "~12.1.1",
"@angular/platform-browser-dynamic": "~12.1.1",
"@angular/router": "~12.1.1",
"@ionic-native/core": "^5.36.0",
"@ionic-native/deeplinks": "^5.36.0",
"@ionic-native/facebook": "^5.36.0",
"@ionic-native/firebase-authentication": "^4.20.0",
"@ionic-native/geolocation": "^5.20.0",
"@ionic-native/sign-in-with-apple": "^5.36.0",
"@ionic-native/twitter-connect": "^5.36.0",
"@ionic/angular": "^5.7.0",
"cordova-plugin-compat": "1.2.0",
"cordova-plugin-customurlscheme": "5.0.2",
"cordova-plugin-facebook-connect": "^3.1.1",
"cordova-plugin-inappbrowser": "5.0.0",
"cordova-universal-links-plugin-fix": "1.2.1",
"firebase": "^9.0.1",

I have added localhost to my authorized domain as well (which is added by default):

My guess is this is due to the origin of ionic apps being "ionic://localhost" instead of "http://localhost".
My Ionic version is also latest which is recommended by Firebase: https://firebase.google.com/docs/auth/web/cordova
Any help with this would be appreciated. Thanks

1mrurvl1

1mrurvl11#

原因:在应用密钥(https://console.developers.google.com/apis/credentials/key)的Google API凭据中,接受来自这些HTTP引用(网站)的请求列表中未包含firebase应用域本身(*.firebaseapp.com)。
这必须是一个相当新的要求,因为接受请求只是从我的实际网站域是足够的事先。
来源:https://github.com/firebase/firebase-js-sdk/issues/998

ajsxfq5m

ajsxfq5m2#

我认为授权域部分中的本地主机域应如下所示:http://本地主机:4200

相关问题