简体   繁体   中英

How to use Postman to test a Google App Engine API with Firebase authentication?

I have an API that is running on Google App Engine. I am using the flexible environment with Python. The flexible environment docs point to this example even though the example is for the Standard environment.

The example shows how to use Firebase to authenticate users to access the API using email and password.

It works really fine for the Flexible environment also. As on the example provided by Google, my API checks the authentication using:

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

The problem I am having is with testing. I can't figure out how to use Postman native app to authenticate and send the Authorization parameter on header so my API will respond back.

On Postman Authorization tab, I used the Bearer option. I used the same token from one web session but it was not valid. I also tried with OAuth2 but it is not clear what to fill on some parameters such as scope.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM