I follow the sample in https://auth0.com/docs/quickstart/spa/vanillajs/05-token-renewal.
Here is my silent HTML written in ASP.NET CORE.
<!-- silent.html -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.auth0.com/js/auth0/8.12.0/auth0.min.js"></script>
<script>
var webAuth = new auth0.WebAuth({
domain: '@ViewBag.Domain',
clientID: '@ViewBag.ClientID',
scope: 'openid email user_metadata app_metadata',
responseType: 'token id_token',
redirectUri: 'http://localhost:5000'
});
</script>
<script>
debugger;
webAuth.parseHash(window.location.hash, function (err, response) {
debugger;
console.log(response);
parent.postMessage(err || response, 'http://localhost:5000');
});
</script>
</head>
<body>
</body>
</html>
My javascript application code
//Auth0.js version
<script src="https://cdn.auth0.com/js/auth0/8.12.0/auth0.min.js"></script>
//Initialize Auth0.js
webAuth = new auth0.WebAuth({
domain: AUTH0_DOMAIN,
clientID: AUTH0_CLIENT_ID,
redirectUri: 'http://localhost:5000',
responseType: 'code token id_token',
scope: 'openid email user_metadata app_metadata',
leeway: 60
});
// Renew token
function renewToken() {
webAuth.renewAuth(
{
redirectUri: 'http://localhost:54993/Auth0Management/silent',
usePostMessage: true
},
function(err, result) {
if (err) {
console.log(err);
} else {
setSession(result);
}
}
);
}
//Schedule Renewal
function scheduleRenewal() {
var expiresAt = JSON.parse(localStorage.getItem('expires_at'));
var delay = expiresAt - Date.now();
if (delay > 0) {
setTimeout(function() {
renewToken();
}, delay);
}
}
But I got the following error
{error: “invalid_token”, errorDescription: “state
does not match.”}
Please advices
@jmangelo Hope this will help you reproduce this issue