Auth0 Home Blog Docs

JWT token works from social connections, not from database

jwt
social-connections
database-connections

#1

I’m using Google and Github social connections to get an idToken. This token I then use as a JWT token and it gets validated perfectly by my hapi.js back end using the hapi-auth-jwt2 library. I do the fetching and collecting of the token using the standard auth0.js library, with callback url where I taken the id_token from the callback URL. All good and works as designed.

I also integrated the database username/password option, and I get back an authResult object with and idToken. However, this token is always invalid according to my backend.
It looks exactly correct and I double checked and debugged to make sure correctly formed token is sent to my back end, but not luck.

Is this a bug or am I missing something completely?


#2

The tokens you send to your backend should be the access_token rather than the id_token. I suggest reading through our API Authorization docs and our Hapi JS quickstart:


#3

Hi Prashant,

thanks for the quick answer. I’m afraid I do not really understand the whole API auth addition. I setup my Vue.js app in the frontend and the Hapi.JS back end according to the Single Page App tutorial: https://auth0.com/blog/vuejs2-authentication-tutorial/ This works great. Just to be clear: my API just functions as the backend for my Vue.js app: there is no usage of the API outside of that.


#4