{"id":349,"date":"2015-08-04T23:36:00","date_gmt":"2015-08-04T23:36:00","guid":{"rendered":"https:\/\/cms.enriquechavez.co\/?p=349"},"modified":"2021-10-30T00:41:13","modified_gmt":"2021-10-30T00:41:13","slug":"json-web-token-authentication-for-wp-rest-api","status":"publish","type":"post","link":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/","title":{"rendered":"JSON Web Token Authentication for WP REST API"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Version 2.0 of the WP REST API plugin is coming with new cool features and arrangements and every day more projects are using the <a href=\"https:\/\/github.com\/WP-API\/WP-API\" target=\"_blank\" rel=\"noreferrer noopener\">WP REST API<\/a> to build mobile and web apps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Lately, I&#8217;ve been playing with the WP REST API, and even the plugin offers three authentication methods I found some issues trying to implement it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In a recent project, I&#8217;ve been working with an AngularJS app with a NodeJS based API, and I use the <a href=\"https:\/\/tools.ietf.org\/html\/rfc7519\" target=\"_blank\" rel=\"noreferrer noopener\">JSON Web Token<\/a> as an authentication method, and let me tell you that works great.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>JSON Web Tokens are an open, industry standard <a href=\"https:\/\/tools.ietf.org\/html\/rfc7519\" target=\"_blank\" rel=\"noreferrer noopener\">RFC 7519<\/a> method for representing claims securely between two parties.<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">For sure, a JWT-based authentication is a must to work with the WP REST API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/github.com\/Tmeister\/wp-api-jwt-auth\" target=\"_blank\" rel=\"noreferrer noopener\">WP API JWT AUTH<\/a> is my last pet project and is a simple plugin to add JSON Web Token (JWT) Authentication to WP REST API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can find all the plugin details, requirements, and usage samples in the <a href=\"https:\/\/github.com\/Tmeister\/wp-api-jwt-auth\" target=\"_blank\" rel=\"noreferrer noopener\">Github Repo<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can add requests or report a bug in the <a href=\"https:\/\/github.com\/Tmeister\/wp-api-jwt-auth\/issues\" target=\"_blank\" rel=\"noreferrer noopener\">Github Issues Page<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, I will work on a <a href=\"https:\/\/enriquechavez.co\/creating-an-application-using-wp-rest-api-and-angularjs\/\" target=\"_blank\" rel=\"noreferrer noopener\">sample project to use the WP API JWT AUTH<\/a> in a real-world app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Said that I encourage you to play with the plugin and let me know if you think that need something else.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/wordpress.org\/plugins\/jwt-authentication-for-wp-rest-api\/\">Now Available in the WordPress.org Official Repo&nbsp;<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Version 2.0 of the WP REST API plugin is coming with new cool features and arrangements and every day more projects are using the WP REST API to build mobile and web apps.<\/p>\n","protected":false},"author":1,"featured_media":350,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[244],"tags":[],"class_list":["post-349","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-plugins"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JSON Web Token Authentication for WP REST API - Enrique Ch\u00e1vez Fullstack Developer<\/title>\n<meta name=\"description\" content=\"WordPress JSON Web Token Authentication allows you to do REST API authentication via token.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JSON Web Token Authentication for WP REST API - Enrique Ch\u00e1vez Fullstack Developer\" \/>\n<meta property=\"og:description\" content=\"WordPress JSON Web Token Authentication allows you to do REST API authentication via token.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/\" \/>\n<meta property=\"og:site_name\" content=\"Enrique Ch\u00e1vez Fullstack Developer\" \/>\n<meta property=\"article:published_time\" content=\"2015-08-04T23:36:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-10-30T00:41:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Tmeister\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tmeister\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/\"},\"author\":{\"name\":\"Tmeister\",\"@id\":\"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/52f69f25d6b54a137e9bb885dd20cdf8\"},\"headline\":\"JSON Web Token Authentication for WP REST API\",\"datePublished\":\"2015-08-04T23:36:00+00:00\",\"dateModified\":\"2021-10-30T00:41:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/\"},\"wordCount\":237,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/52f69f25d6b54a137e9bb885dd20cdf8\"},\"image\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg\",\"articleSection\":[\"WordPress Plugins\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/\",\"url\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/\",\"name\":\"JSON Web Token Authentication for WP REST API - Enrique Ch\u00e1vez Fullstack Developer\",\"isPartOf\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg\",\"datePublished\":\"2015-08-04T23:36:00+00:00\",\"dateModified\":\"2021-10-30T00:41:13+00:00\",\"description\":\"WordPress JSON Web Token Authentication allows you to do REST API authentication via token.\",\"breadcrumb\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#primaryimage\",\"url\":\"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg\",\"contentUrl\":\"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg\",\"width\":1000,\"height\":500},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cms.enriquechavez.co\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JSON Web Token Authentication for WP REST API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cms.enriquechavez.co\/#website\",\"url\":\"https:\/\/cms.enriquechavez.co\/\",\"name\":\"Enrique Ch\u00e1vez Fullstack Developer\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/52f69f25d6b54a137e9bb885dd20cdf8\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cms.enriquechavez.co\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/52f69f25d6b54a137e9bb885dd20cdf8\",\"name\":\"Tmeister\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/093cb2781a999a54a8c7bf7202c241adc5b45a3a36a9cf7d01807d724f2164d9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/093cb2781a999a54a8c7bf7202c241adc5b45a3a36a9cf7d01807d724f2164d9?s=96&d=mm&r=g\",\"caption\":\"Tmeister\"},\"logo\":{\"@id\":\"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/image\/\"},\"description\":\"Enrique Chavez is a full-stack developer with almost 20 years of experience in the industry. he is an extremely versatile developer working on a plethora of projects, from startups to established companies.\",\"sameAs\":[\"https:\/\/enriquechavez.co\"],\"url\":\"https:\/\/cms.enriquechavez.co\/author\/echavez\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JSON Web Token Authentication for WP REST API - Enrique Ch\u00e1vez Fullstack Developer","description":"WordPress JSON Web Token Authentication allows you to do REST API authentication via token.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/","og_locale":"en_US","og_type":"article","og_title":"JSON Web Token Authentication for WP REST API - Enrique Ch\u00e1vez Fullstack Developer","og_description":"WordPress JSON Web Token Authentication allows you to do REST API authentication via token.","og_url":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/","og_site_name":"Enrique Ch\u00e1vez Fullstack Developer","article_published_time":"2015-08-04T23:36:00+00:00","article_modified_time":"2021-10-30T00:41:13+00:00","og_image":[{"width":1000,"height":500,"url":"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg","type":"image\/jpeg"}],"author":"Tmeister","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tmeister","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#article","isPartOf":{"@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/"},"author":{"name":"Tmeister","@id":"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/52f69f25d6b54a137e9bb885dd20cdf8"},"headline":"JSON Web Token Authentication for WP REST API","datePublished":"2015-08-04T23:36:00+00:00","dateModified":"2021-10-30T00:41:13+00:00","mainEntityOfPage":{"@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/"},"wordCount":237,"commentCount":0,"publisher":{"@id":"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/52f69f25d6b54a137e9bb885dd20cdf8"},"image":{"@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#primaryimage"},"thumbnailUrl":"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg","articleSection":["WordPress Plugins"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/","url":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/","name":"JSON Web Token Authentication for WP REST API - Enrique Ch\u00e1vez Fullstack Developer","isPartOf":{"@id":"https:\/\/cms.enriquechavez.co\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#primaryimage"},"image":{"@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#primaryimage"},"thumbnailUrl":"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg","datePublished":"2015-08-04T23:36:00+00:00","dateModified":"2021-10-30T00:41:13+00:00","description":"WordPress JSON Web Token Authentication allows you to do REST API authentication via token.","breadcrumb":{"@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#primaryimage","url":"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg","contentUrl":"https:\/\/cms.enriquechavez.co\/wp-content\/uploads\/2021\/10\/json-web-token-auth-wp-api.jpeg","width":1000,"height":500},{"@type":"BreadcrumbList","@id":"https:\/\/cms.enriquechavez.co\/json-web-token-authentication-for-wp-rest-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cms.enriquechavez.co\/"},{"@type":"ListItem","position":2,"name":"JSON Web Token Authentication for WP REST API"}]},{"@type":"WebSite","@id":"https:\/\/cms.enriquechavez.co\/#website","url":"https:\/\/cms.enriquechavez.co\/","name":"Enrique Ch\u00e1vez Fullstack Developer","description":"","publisher":{"@id":"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/52f69f25d6b54a137e9bb885dd20cdf8"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cms.enriquechavez.co\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/52f69f25d6b54a137e9bb885dd20cdf8","name":"Tmeister","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/093cb2781a999a54a8c7bf7202c241adc5b45a3a36a9cf7d01807d724f2164d9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/093cb2781a999a54a8c7bf7202c241adc5b45a3a36a9cf7d01807d724f2164d9?s=96&d=mm&r=g","caption":"Tmeister"},"logo":{"@id":"https:\/\/cms.enriquechavez.co\/#\/schema\/person\/image\/"},"description":"Enrique Chavez is a full-stack developer with almost 20 years of experience in the industry. he is an extremely versatile developer working on a plethora of projects, from startups to established companies.","sameAs":["https:\/\/enriquechavez.co"],"url":"https:\/\/cms.enriquechavez.co\/author\/echavez\/"}]}},"_links":{"self":[{"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/posts\/349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/comments?post=349"}],"version-history":[{"count":3,"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/posts\/349\/revisions"}],"predecessor-version":[{"id":370,"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/posts\/349\/revisions\/370"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/media\/350"}],"wp:attachment":[{"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/media?parent=349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/categories?post=349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cms.enriquechavez.co\/wp-json\/wp\/v2\/tags?post=349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}