Auth0 Home Blog Docs

No id_token being return in the auth0-js function webAuth.client.login()

id_token
login
auth0-js

#1

I am currently using the auth0-js SDK and attempting to use the webAuth.client.login function. I am not seeing an id_token in the response.

webAuth.client.login({
  username: user.email,
  password: user.password,
  realm: 'Username-Password-Authentication'
}, (err, response) => { console.log(JSON.stringify(response)) })

The response is:

{"accessToken":"asdf","refreshToken":"asdfa","scope":"profile email offline_access","expiresIn":1814400,"tokenType":"Bearer"}

What could be causing no id_token in the response?


#2

You did not include the openid scope so the request is not being considered as a normal OIDC request and as such is not returning an ID token.


#3

That’s exactly it. I should have clarified I was intializing it like this

let webAuth = new WebAuth({
domain: ‘stg-helloinspire.auth0.com’,
clientID: this.config.auth0.clientId,
scope: ‘open_id profile email offline_access’,
audience: this.config.auth0.audience,
redirectUri: this.config.auth0.callbackURL,
responseType: ‘token id_token’
})

The underscore in open_id was the problem.


#4