# JWT token works from social connections, not from database

**URL:** <https://community.auth0.com/t/jwt-token-works-from-social-connections-not-from-database/7434>\
**Category:** Get Help\
**Tags:** jwt, database-connections, social-connections\
**Created:** [July 10, 2017, 12:48am UTC](https://community.auth0.com/t/jwt-token-works-from-social-connections-not-from-database/7434 "2017-07-10T00:48:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![admin15](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@admin15](https://community.auth0.com/u/admin15)\
**Post date:** [July 10, 2017, 12:48am UTC](https://community.auth0.com/t/jwt-token-works-from-social-connections-not-from-database/7434/1 "2017-07-10T00:48:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [July 10, 2017, 8:35am UTC](https://community.auth0.com/t/jwt-token-works-from-social-connections-not-from-database/7434/2 "2017-07-10T08:35:53Z")

</div>

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:

- [Authentication and Authorization Flows](https://auth0.com/docs/api-auth)
- [Auth0 Backend/API Quickstarts](https://auth0.com/docs/quickstart/backend/hapi)

---

<div class="post-metadata">

**Author:** ![admin15](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@admin15](https://community.auth0.com/u/admin15)\
**Post date:** [July 10, 2017, 4:30pm UTC](https://community.auth0.com/t/jwt-token-works-from-social-connections-not-from-database/7434/3 "2017-07-10T16:30:48Z")

</div>

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: [The Complete Guide to Vue.js User Authentication with Auth0](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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:55am UTC](https://community.auth0.com/t/jwt-token-works-from-social-connections-not-from-database/7434/4 "2018-03-02T05:55:14Z")

</div>


