Auth0 Home Blog Docs

Renew token issue



I have really problem with token renew in my Angular4 spa. Following this tutorial I got login_required or contest error. Below my renewToken method:

public renewToken() {
          scope: 'openid',
          audience: '...',
          redirectUri: environment.DOMAIN + ':3000/silent.html',          
          usePostMessage: true
        }, (err, authResult) => {
          if (err) {
          } else {
            console.log("Auth result:", authResult);

I don’t get this error even in err variable but in authResult console.log.
This issue occurs also after disable social auth.
Below my silent.html file:

<!doctype html>
  <meta charset="utf-8">
  <script src=""></script>
    var webAuth = new auth0.WebAuth({
      domain: '...',
      clientID: '...',
    webAuth.parseHash(window.location.hash, function (err, response) {
      parent.postMessage(err || response, '...');

Will be glad if anyone can help me with that stuff.


I gave it a test using the same Auth0.js version you have in your silent callback handler and could not reproduce the same exact error login_required you mentioned in the question. That error condition is not unexpected or said it another way it’s a perfectly valid response for the case where there is no pre-existing end-user session or the session exists but some circumstances changed and the session cannot be used to complete the authentication request.

Assuming you’re testing this by performing a login immediately before trying to renew then the error would indeed not be expected unless there’s some issue in the session establishment (it’s based on cookies so it’s always a bit dependent on the user-agent).

Also have in mind that if you’re using social connections then as instructed in the README of the linked step:

If you see an error on renewal saying login_required, that means you may be using the Auth0 dev keys for whichever social login you’re testing. You’ll need to add your own keys for this to work.

If the previously does not apply, the recommendation would be for you to inspect the network traffic to check if it can be a cookie related issue (the /authorize request triggered by renewal would not include the necessary cookies) or at least to try to find additional information. It can also be helpful to update your question with an HTTP trace showing a login transaction being completed and the immediate authentication renewal failing (have in mind that HTTP traces can include sensitive information so you may want to redact it before sharing).