JSONError: Unexpected token '<' at 3:1 <!-- Copyright (C) Microsoft Corporation. All rights reserved. -->

Dear team,

I’m trying to renew a token automaticaly into Postman. I’m using this script:

'i’m referring to the article How to Automate OAuth2 Token Renewal in Postman | by Allen Helton | Medium

// Refresh the OAuth token if necessary
var tokenDate = new Date(2010,1,1);
var tokenTimestamp = pm.environment.get(“OAuth_Timestamp”);
if(tokenTimestamp){
tokenDate = Date.parse(tokenTimestamp);
}
var expiresInTime = pm.environment.get(“ExpiresInTime”);
if(!expiresInTime){
expiresInTime = 300000; // Set default expiration time to 5 minutes
}if((new Date() - tokenDate) >= expiresInTime)
{
pm.sendRequest({
url: pm.variables.get(“Auth_Url”),
method: ‘POST’,
header: {
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/x-www-form-urlencoded’,
‘Authorization’: pm.variables.get(“Basic_Auth”)
}
}, function (err, res) {
pm.environment.set(“OAuth_Token”, res.json().access_token);
pm.environment.set(“OAuth_Timestamp”, new Date());

 // Set the ExpiresInTime variable to the time given in the response if it exists
        if(res.json().expires_in){
            expiresInTime = res.json().expires_in * 1000;
        }
        pm.environment.set("ExpiresInTime", expiresInTime);
  }

I have this message error:

JSONError: Unexpected token '<' at 3:1 <!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
^

I don't know where it comes from despite the documentation.

Thanks for your help

Regards