You might want to consider calling the token something like “currentToken” when parsing the response, and then use this to set the environment variable.
This way, you know that you aren’t having scope issues.
I also don’t see why you would want this as a global variable.
The tokens are usually confidential information, which is why you want them in the current values in an Environment variable.