【问题标题】:Firebase Authentication 403 in production but works fine with localhostFirebase Authentication 403 在生产中,但在 localhost 上工作正常
【发布时间】:2022-01-02 14:56:15
【问题描述】:

Firebase 身份验证在 localhost 中运行良好,但在生产中的 google cloud run 项目中失败,仅显示 403,没有详细说明错误原因

这是标题:

> POST /api/account/auth2/ HTTP/2 Host: appsite.com User-Agent: Mozilla/5.0
> (Macintosh; Intel Mac OS X 10.15; rv:95.0) Gecko/20100101 Firefox/95.0
> Accept: */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip,
> deflate, br Referer: https://appsite.com/ Content-Type:
> application/x-www-form-urlencoded; charset=UTF-8 X-CSRFToken:
> 6cpDY8qOBRK9XqfWcuLX6eujG85AmOnHp...b5f0j0t7tHy5rmAWCcEDw
> X-Requested-With: XMLHttpRequest Content-Length: 1251 Origin:
> https://appsite.com Connection: keep-alive Cookie:
> csrftoken=6cpDY8qOBRK9XqfWcuLX6eujG85AmOnHpi4IR9rRd...Hy5rmAWCcEDw
> Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: same-origin
> TE: trailers

是的,我在 firebase auth 域中添加了域名。 这里的任何帮助都会很棒。

我正在使用 google gloud python google-auth=2.3.3

decoded_token = auth.verify_id_token(token)
 uid = decoded_token["uid"]

还有我的 Javascript:const provider = new firebase.auth.GoogleAuthProvider();

$('.googleLogin').click(async function () {

    const provider = new firebase.auth.GoogleAuthProvider();
    // [START auth_google_provider_scopes]
    const credential = await firebase.auth().signInWithPopup(provider);
    const idToken = await firebase.auth().currentUser.getIdToken();

    // Send Token to Back End
    return handleMethod(idToken)
});

【问题讨论】:

    标签: python-3.x firebase-authentication


    【解决方案1】:

    这是一个 CSRF 验证失败。 我不得不使用邮递员来弄清楚发生了什么。 以防其他人面临同样的问题。

    • 禁止 (403)

    • CSRF 验证失败。请求中止。

    【讨论】:

      猜你喜欢
      • 2022-01-20
      • 2021-09-12
      • 1970-01-01
      • 1970-01-01
      • 2015-04-22
      • 2017-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多