How to persist an OAuth2 token (or use a refresh token) in Postman collections?

前端 未结 4 2114
一整个雨季
一整个雨季 2021-01-30 05:50

The goal

Be able to run a collection without going through the authorization process of every call individually prior to running the collection.

4条回答
  •  旧时难觅i
    2021-01-30 06:08

    Ok, first enter your OAUTH token URL, click on the Body tab, and fill out these POST parameters: client_id, grant_type, username, password, override.

    Then, click on the Test tab, enter this text and then press Send:

    var data = JSON.parse(responseBody);
    postman.setGlobalVariable("access_token", data.access_token);
    postman.setGlobalVariable("refresh_token", data.refresh_token);
    

    Then enter one of your application URLs, click on the Headers Tab, and enter a parameter Authorization with a value Bearer {{access_token}}. Then click on Send.

    Voila!

提交回复
热议问题