使用pyrebase检索用户信息

编程入门 行业动态 更新时间:2024-10-11 03:24:21
本文介绍了使用pyrebase检索用户信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下Javascript代码,该代码返回了Google身份验证的令牌:

I've got this Javascript code which returns the token for Google Authentication:

<script> function googleLogin(){ var provider = new firebase.auth.GoogleAuthProvider(); firebase.auth().useDeviceLanguage(); firebase.auth().signInWithPopup(provider).then(function(result) { // This gives you a Google Access Token. You can use it to access the Google API. var token = result.credential.accessToken; // The signed-in user info. var user = result.user; // ... alert(token) var csrftoken = '{{ csrf_token }}'; $.post("/api/login", {'csrfmiddlewaretoken': csrftoken, 'token': token}); }).catch(function(error) { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; // The email of the user's account used. var email = error.email; // The firebase.auth.AuthCredential type that was used. var credential = error.credential; // ... }); } </script>

但是,当我尝试将此令牌发送到pyrebase以检索用户信息时,它将返回INVALID_ID_TOKEN错误

But, when I try to send this token to pyrebase to retrieve user information it returns INVALID_ID_TOKEN error

这是我将令牌发送到pyrebase的一段代码:

This is the piece of code in which I send the token to pyrebase:

user_info = auth.get_account_info(token)

这是错误:

requests.exceptions.HTTPError: [Errno 400 Client Error: Bad Request for url: www.googleapis/identitytoolkit/v3/relyingparty/getAccountInfo?key=AIzaSyBUH-4_qFvkszGWxII8HyooOJNDqbltDKo] { "error": { "code": 400, "message": "INVALID_ID_TOKEN", "errors": [ { "message": "INVALID_ID_TOKEN", "domain": "global", "reason": "invalid" } ] } }

推荐答案

我正在发送Google Access令牌,而不是Firebase令牌

I was sending Google Access Token, not Firebase Token

更多推荐

使用pyrebase检索用户信息

本文发布于:2023-11-06 08:32:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563202.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户信息   pyrebase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!