首页 > 解决方案 > 如何使用 Postman 通过 Firebase 身份验证测试 Google App Engine API?

问题描述

我有一个在 Google App Engine 上运行的 API。我正在使用 Python 的灵活环境。即使该示例适用于标准环境,灵活环境文档也指向此示例。

该示例展示了如何使用 Firebase 对用户进行身份验证,以便使用电子邮件和密码访问 API。

它也适用于灵活的环境。正如 Google 提供的示例一样,我的 API 使用以下方法检查身份验证:

id_token = request.headers['Authorization'].split(' ').pop()
claims = google.oauth2.id_token.verify_firebase_token(
    id_token, HTTP_REQUEST)
if not claims:
    return 'Unauthorized', 401

我遇到的问题是测试。我不知道如何使用 Postman 本机应用程序进行身份验证并在标头上发送 Authorization 参数,以便我的 API 做出响应。

在 Postman Authorization 选项卡上,我使用了 Bearer 选项。我在一个网络会话中使用了相同的令牌,但它无效。我也尝试过使用 OAuth2,但不清楚在某些参数(例如范围)上填写什么内容。

标签: firebasegoogle-app-enginefirebase-authenticationpostman

解决方案


This page should help: https://developers.google.com/identity/protocols/OAuth2WebServer. Look at the HTTP/REST examples to help configure your Postman requests.

If you can use curl, or have Postman give you equivalent curl commands, you should post them here, with the actual auth tokens redacted. You may get more help that way.


推荐阅读