{"id":2115,"date":"2018-08-29T18:34:35","date_gmt":"2018-08-29T17:34:35","guid":{"rendered":"http:\/\/www.jurecuhalev.com\/blog\/?p=2115"},"modified":"2018-08-29T18:34:35","modified_gmt":"2018-08-29T17:34:35","slug":"a-tip-on-connecting-djangorestframework-jsonapi-jwt-with-ember-simple-auth","status":"publish","type":"post","link":"https:\/\/www.jurecuhalev.com\/blog\/a-tip-on-connecting-djangorestframework-jsonapi-jwt-with-ember-simple-auth\/","title":{"rendered":"A tip on connecting djangorestframework{-jsonapi, -jwt} with ember-simple-auth"},"content":{"rendered":"\n<p>The main issue that I&#8217;ve encountered was the fact that djangorestframework-jsonapi wanted to get requests in different format that ember-simple-auth sent them. This was great for the rest of my Ember app, but authentication didn&#8217;t work. The solution is to include both <code>rest_framework.parsers.JSONParser<\/code> and <code>rest_framework_json_api.parsers.JSONParser<\/code> in the mix. The final result in <code>settings.py<\/code>\u00a0that worked for me was:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>REST_FRAMEWORK = {\n        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',\n        'rest_framework.authentication.SessionAuthentication',\n        'rest_framework.authentication.BasicAuthentication',\n        'rest_framework.authentication.TokenAuthentication',\n    ),\n    'DEFAULT_PARSER_CLASSES': (\n        'rest_framework.parsers.JSONParser',\n        'rest_framework_json_api.parsers.JSONParser',\n        ...\n    ),\n    'DEFAULT_RENDERER_CLASSES': (\n        'rest_framework_json_api.renderers.JSONRenderer',\n        'rest_framework.renderers.JSONRenderer',\n        ...\n    ),\n    'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata'\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The main issue that I&#8217;ve encountered was the fact that djangorestframework-jsonapi wanted to get requests in different format that ember-simple-auth sent them. This was great for the rest of my Ember app, but authentication didn&#8217;t work. The solution is to include both rest_framework.parsers.JSONParser and rest_framework_json_api.parsers.JSONParser in the mix. The final result in settings.py\u00a0that worked for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[925],"tags":[],"class_list":["post-2115","post","type-post","status-publish","format-standard","hentry","category-ember-js"],"acf":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/posts\/2115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/comments?post=2115"}],"version-history":[{"count":2,"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/posts\/2115\/revisions"}],"predecessor-version":[{"id":2118,"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/posts\/2115\/revisions\/2118"}],"wp:attachment":[{"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/media?parent=2115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/categories?post=2115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jurecuhalev.com\/blog\/wp-json\/wp\/v2\/tags?post=2115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}