In auth0 lock, how to update id_token?

I am creating a cordova mobile app and am trying to use the auth0 lock API. I am having problems with the update token. I can return the update token in authResult, but I can’t figure out how to really update id_token (I suppose I could write REST calsl myself)

There seems to be a method in v9 docs: https://auth0.com/docs/libraries/lock/v9/using-a-refresh-token

lock.getClient().refreshToken(refresh_token, function (err, delegationResult) { // Get here the new JWT via delegationResult.id_token }); 

However, in v10 lock, this method no longer exists: https://auth0.com/docs/libraries/lock/v10/api

Can someone tell me if there is a way to update the token using the blocking API?

+5
source share
1 answer

First you need to include the Auth0 script tag in your HTML:

  <script src="https://cdn.auth0.com/js/lock/10.8/lock.min.js"></script> 

Or, if you installed from npm, you may need Auth0:

  var Auth0 = require("auth0-js"); 

In V10, you create an instance of the Auth0 client (separate from the Auth0Lock instance), which has a refreshToken() function:

 var auth0 = new Auth0({clientID: YOUR_CLIENT_ID, domain: YOUR_AUTH0_DOMAIN}); ... auth0.refreshToken(refresh_token_here, (err, resp) => { // resp: {expires_in: 36000, id_token: "id_token here", token_type: "Bearer"} } 

The same can be achieved with the getDelegationToken() function:

 auth0.getDelegationToken({ client_id: YOUR_CLIENT_ID, grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer", refresh_token: refresh_token_here, scope: "openid", api_type: "auth0" }, (err, resp) => { // resp: {expires_in: 36000, id_token: "id_token here", token_type: "Bearer"} }); 
+1
source

All Articles