有没有办法使用''auth REST API''从我的firebase auth用户那里获得“emailVerified”?

Posted

技术标签:

【中文标题】有没有办法使用\'\'auth REST API\'\'从我的firebase auth用户那里获得“emailVerified”?【英文标题】:Is there any way to get the "emailVerified" from my firebase auth user using ''auth REST API''?有没有办法使用''auth REST API''从我的firebase auth用户那里获得“emailVerified”? 【发布时间】:2019-08-26 10:18:50 【问题描述】:

我目前使用 firebase 作为我的后端网络服务器,并且我使用 auth REST API 来验证我的应用程序中的用户(使用电子邮件和密码登录)。我的问题是我想知道是否有一个 http 请求,我可以通过它做出响应,包括登录的电子邮件是否经过验证,我尝试将其余 API 与 firebase-Auth 包混合,但它没有不工作。

我刚刚找到了“setAccountInfo”端点,但要让它工作,我需要发送给用户的确认电子邮件中的“oobCode”,我猜我无法自动获得它。 谁能帮我解决这个问题?

【问题讨论】:

您好,您能告诉我们您的尝试吗? 【参考方案1】:

我认为您可以使用 getAccountInfo 端点来做到这一点,它会返回以下包含 emailVerified 属性的有效负载(来自文档的示例):


  "users": [
    
      "localId": "ZY1rJK0...",
      "email": "user@example.com",
      "emailVerified": false,
      "displayName": "John Doe",
      "providerUserInfo": [
        
          "providerId": "password",
          "displayName": "John Doe",
          "photoUrl": "http://localhost:8080/img1234567890/photo.png",
          "federatedId": "user@example.com",
          "email": "user@example.com",
          "rawId": "user@example.com",
          "screenName": "user@example.com"
        
      ],
      "photoUrl": "https://lh5.googleusercontent.com/.../photo.jpg",
      "passwordHash": "...",
      "passwordUpdatedAt": 1.484124177E12,
      "validSince": "1484124177",
      "disabled": false,
      "lastLoginAt": "1484628946000",
      "createdAt": "1484124142000",
      "customAuth": false
    
  ]

示例请求(来自文档,粘贴以供参考):

curl
'https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=[API_KEY]'
\
-H 'Content-Type: application/json' --data-binary '"idToken":"[FIREBASE_ID_TOKEN]"'

在上面的示例中,您可以将 [API_KEY] 替换为 Web API 密钥 您的 Firebase 项目和 [FIREBASE_ID_TOKEN] 与用户的 Firebase ID 令牌。


PS:我没有尝试过您在问题末尾提到的setAccountInfo端点,但我认为它用于发送(POST)通过电子邮件收到的验证码(来自doc:-> "oobCode: 发送到用户邮箱进行邮箱验证的操作码。")

【讨论】:

我没有注意到 setAccountInfo 端点存在,它确实有效,它给了我需要的所有信息,非常感谢

以上是关于有没有办法使用''auth REST API''从我的firebase auth用户那里获得“emailVerified”?的主要内容,如果未能解决你的问题,请参考以下文章

有没有办法使用 Django REST 框架中的可浏览 API 上传文件?

使用django-rest-auth自带登录注册api

如何使用 REST + CodeceptJS 测试 API,访问受 Auth0 保护?

在nodejs中使用rest auth api

Laravel Rest API Google Auth 在 Angular

在安装 tymon/jwt-auth 后的 laravel Backend REST API 应用程序中再次遇到 CORS 错误