Last active
July 22, 2023 08:41
-
-
Save AliMilani/5e7f90664bc8d0b0a46c7cd8f2d60fe0 to your computer and use it in GitHub Desktop.
This Postman test extracts the "authorization" and "x-refresh-token" headers from the response and stores them in environment variables "USER_ACCESS_TOKEN" and "USER_REFRESH_TOKEN" if they exist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let data = JSON.parse(responseBody); | |
var authorization = pm.response.headers.get('authorization') | |
var refreshToken = pm.response.headers.get('x-refresh-token') | |
if (!authorization) return | |
if (authorization) pm.environment.set("USER_ACCESS_TOKEN", authorization?.split(' ')[1]); | |
if (refreshToken) pm.environment.set("USER_REFRESH_TOKEN", refreshToken); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment