# JSON JWT Tokens not working

**URL:** <https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856>\
**Category:** REST API\
**Created:** [November 29, 2015, 5:09pm UTC](https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856 "2015-11-29T17:09:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![charliefinale](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@charliefinale](https://community.dreamfactory.com/u/charliefinale)\
**Post date:** [November 29, 2015, 5:09pm UTC](https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856/1 "2015-11-29T17:09:20Z")

</div>

Hi, I have been working with version 1.9 for a short while and have had no problem with tokens. I use the Google REST console to test the API and first I get a token using [http://xxx/api/v2/user/session](http://xxx/api/v2/user/session) and putting username and password in the body and of the app name in the header…as described like this and POST

{  
“email”: "test2@zegaphone.com",  
“password”: “user123”,  
“duration”: 3600  
}  
and setting in the header

X-DreamFactory-Application-Name to be my app name

But when I do exactly the same thing in V2 I get a reply that appears to be a page written by Yahoo!

Here are the first few lines of it…

 /\* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html \*/ html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,i

Any ideas anyone…I am baffled! Where on earth does this page come from?

---

<div class="post-metadata">

**Author:** ![charliefinale](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@charliefinale](https://community.dreamfactory.com/u/charliefinale)\
**Post date:** [November 29, 2015, 5:11pm UTC](https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856/2 "2015-11-29T17:11:46Z")

</div>

Somehow the Yahoo page got knocked off, but my question is any ideas whiy I get a Yahoo HTML page when I do the same POST to V2 as I did to 1.9?

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [November 29, 2015, 11:47pm UTC](https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856/3 "2015-11-29T23:47:34Z")

</div>

Check out these links.

[https://wiki.dreamfactory.com/DreamFactory/Tutorials/Logging\_in](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Logging_in)  
[https://wiki.dreamfactory.com/DreamFactory/Tutorials/Logging\_out](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Logging_out)  
[https://wiki.dreamfactory.com/DreamFactory/Tutorials/Access\_Using\_API\_Key](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Access_Using_API_Key)  
[https://wiki.dreamfactory.com/DreamFactory/Tutorials/Access\_Using\_JWT](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Access_Using_JWT)  
[https://wiki.dreamfactory.com/DreamFactory/Tutorials/Access\_Using\_JWT\_and\_API\_Key](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Access_Using_JWT_and_API_Key)  
[https://wiki.dreamfactory.com/DreamFactory/Tutorials/Refreshing\_a\_JWT](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Refreshing_a_JWT)  
[https://wiki.dreamfactory.com/DreamFactory/Tutorials/Forever\_sessions](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Forever_sessions)

---

<div class="post-metadata">

**Author:** ![charliefinale](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@charliefinale](https://community.dreamfactory.com/u/charliefinale)\
**Post date:** [December 5, 2015, 5:02pm UTC](https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856/4 "2015-12-05T17:02:31Z")

</div>

Thank you, these tutorials cracked it for me. I had the JWT token in the header but I was missing the API key. For those reading this the API key is autogenerated under Apps and there you assign a role which you have previous created. The role gives access to the services and voila a perfectly firmed system for access rights.

---

<div class="post-metadata">

**Author:** ![smilesinblues](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@smilesinblues](https://community.dreamfactory.com/u/smilesinblues)\
**Post date:** [June 29, 2016, 8:28pm UTC](https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856/5 "2016-06-29T20:28:57Z")

</div>

Similar to [https://wiki.dreamfactory.com/DreamFactory/Tutorials/Access\_Using\_JWT\_and\_API\_Key](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Access_Using_JWT_and_API_Key)

I expected the json calls to not work without JWT. But right now I am able to make calls with just API\_KEY. How do I make sure that the JWT is a must for the json to show.

---

<div class="post-metadata">

**Author:** ![formerstaff](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/formerstaff/32/1133_2.png) [@formerstaff](https://community.dreamfactory.com/u/formerstaff)\
**Post date:** [July 11, 2016, 7:03pm UTC](https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856/6 "2016-07-11T19:03:54Z")

</div>

It seems that your api key has a default role attached to it. Remove the default role for the app (api key) and then you will require a session token as well.

---

<div class="post-metadata">

**Author:** ![smilesinblues](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@smilesinblues](https://community.dreamfactory.com/u/smilesinblues)\
**Post date:** [July 16, 2016, 3:14pm UTC](https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856/7 "2016-07-16T15:14:46Z")

</div>

Thanks Drew. I suppose that if I remove API option from the roles-access-requester then it will force JWT on each call. How will we put the JWT logic etc into each request, as of now the calls have stopped working.

Is there a step by step tutorial on this as I suppose this is one of the most critical things to do in deploying api.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [July 16, 2016, 4:19pm UTC](https://community.dreamfactory.com/t/json-jwt-tokens-not-working/1856/8 "2016-07-16T16:19:45Z")

</div>

Check out this info in the docs:

[https://wiki.dreamfactory.com/DreamFactory/Tutorials/Authentication\_and\_Authorization](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Authentication_and_Authorization)  
[https://wiki.dreamfactory.com/DreamFactory/Features/Auth](https://wiki.dreamfactory.com/DreamFactory/Features/Auth)
