Postman Tests not setting bearer-token correctly

I have a large collection of about 60 requests. I have access tokens and refresh tokens. My refresh tokens are long lived while my access tokens are set to expire every 15 minutes. Because of this I have the following code that kicks off every time I do a new login:

pm.environment.set(“bearer-token”, “access_token”);
pm.collectionVariables.set(“bearer-token”, “access_token”);
pm.globals.set(“bearer-token”, “access_token”);

The problem is that code does not capture the entire token and add it as the request environment variable. Here is a sample token that my api returns:

lyJ0eXAiOiJKV1PiLCJhbGciOiJIUzI1NiJ9.elJpPXQiPjE1Nzk1MNM0NTIzIm5iZiI6MTU3OTYxMzQ1MiwianRpIjoiMWFmNTdhYzEtZTRhMy00M2NiLWEzODYtMjhiNjRhZmJjZmIxIiwiZXhwIjoxNTc5NjE0MzUyLCJzdWIiOiJvcnJldHQiLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MifQ.SZDNvMqU0M9bAm8ux0ZH_JfBtUEjHcUQV2mKwZYhmnA

Is my token too long for the script to wok?

Hi @omorgan!

Is that the exact code you’re using? pm.environment.set(“bearer-token”, “access_token”); would set a “bearer-token” variable with the value “access_token”. How are these tokens being generated, and where are they being stored?