Setting Up Authorization

Hi Community! New Postman user, semi-technical so be kind :smile:

I’m having trouble setting up my Authorization for my tests. I’m getting a token expired response for my GETs and POSTs but I know the token generated isn’t expired.

I’m just trying to get my Authorization to use the Bearer token we generate from our GET /token endpoint for each new call.

We have an endpoint where we perform a GET to receive a Bearer Token. The response looks like this:
{“token”:“eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Ijg2ZTEwYjM4LTFiZDYtNGFiNC04YjlmLTVhNmI4ZDg3MjRmNSIsIm5iZiI6MTUxNTcwNzg1MiwiZXhwIjoxNTE1NzA5MDUyLCJpYXQiOjE1MTU3MDc4NTJ9.hGblCa8kyoeO9QaAPbKylIVxOkrZGxKxhqrt9Um1cAQ”,
“expiresAt”: “2018-01-11T22:17:32.8517349Z”}

In the Edit Collection section, I have the Authorization setup to use results from GET /token…. I have a feeling this is where my mistake is.

When I use a GET that uses the Collection-level authorization, I’m not getting the right token.

GET /v1/api/contact?id=WZzl HTTP/1.1
Host: hidden host name
Ocp-Apim-Subscription-Key: 2ace9fd1e8ac4d448e179b5d069f2c81
Authorization: Bearer "token" from GET /token.....
Cache-Control: no-cache
Postman-Token: 891004f1-68cf-51ec-0eac-048998d80598

Hi @lucasisola - you’ll need to copy and paste the actual token into the Token box. Alternatively, you can use a variable in the authorization box: {{token}}, and use this in the test script of your GET request:

pm.globals.set("token", pm.response.json().token);

1 Like

Thanks! @abhijit. I really appreciate your reply!! :grinning: