julienderoche-8922 avatar image
0 Votes"
julienderoche-8922 asked sikumars-msft commented

POSTMAN, Issue with automatical renewal token script with azure AD

Hello everyone,

I have this issue when i test the pre-request script "JSONError: Unexpected token '<' at 3:1 <!-- Copyright (C) Microsoft Corporation. All rights reserved. -->" and i don't know where it comes from.
I saw few articles about this issue but i'm still blocked. Here my pre-script

// Refresh the OAuth token if necessary
var tokenDate = new Date(2010,1,1);
var tokenTimestamp = pm.environment.get("OAuth_Timestamp");
tokenDate = Date.parse(tokenTimestamp);
var expiresInTime = pm.environment.get("ExpiresInTime");
expiresInTime = 300000; // Set default expiration time to 5 minutes
}if((new Date() - tokenDate) >= expiresInTime)
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
         expiresInTime = res.json().expires_in * 1000;
     pm.environment.set("ExpiresInTime", expiresInTime);


Maybe you'll see what i can't :)

Thank you very much


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @julienderoche-8922,

Thanks for reaching out and apologies for delayed response.

I would like to reach out to you and see if you were able to fix the issue, in case if you still experience same issue if you try to update recent version of POSTMAN tool and see if the issue reproducible? because this seems to ADAL library related exception. Thanks.

0 Votes 0 ·

0 Answers