Auth0 Home Blog Docs

renewAuth errors

renewauth

#1

I’m using the code from this PR: https://github.com/auth0/auth0.js/pull/432 and am trying to renew a users idToken. Here is my relevant code:

const auth0 = require('auth0-js')

const auth0client = new auth0.WebAuth({
  domain: process.env.AUTH0_DOMAIN,
  clientID: process.env.AUTH0_CLIENT_ID
})

auth0client.renewAuth({
    audience: '',
    postMessageDataType: 'auth0:silent-authentication',
    redirectUri: window.location.origin + '/auth/silent-callback',
    scope: 'openid app_metadata user_metadata',
    usePostMessage: true
  }, (err, authResult) => {
    if (err) {
      console.log('Failed to renew log in.')
      return callback(err)
    }

And here is the jade file that is used to render /auth/silent-callback:

doctype html
html(lang='en')
  head
    script(type='text/javascript').
      var data = {
        type: 'auth0:silent-authentication',
        hash: window.location.hash
      };
      
      // This page is designed to be loaded in an Iframe
      var result = parent.postMessage(data, "*");

  body

However, I was first getting the error: “Algorithm HS256 is not supported. (Expected algs: [RS256])”. So I went and changed the algorithm to RS256, but then I got the error: “Nonce does not match.”

What am I doing wrong?


#2

Looks like I had to include a nonce in the renewAuth method when using RS256.


#3