oAuth2 Authentication in WordPress using WP OAuth Server and WP API plugins


I am sturggling with how authentication works in my scenario.

I have WordPress site which provides set of custom APIs secured behind oAuth2 Authentication using Wp OAuth Server plugin.

I started with building simple custom endpoint by extending WP REST API (WP API) plugin. I setup up my endpoint as POST /api/v1/projects, where my callback function is even more simple,

function create_projects() {

      // my code to create new project
      return ['code'=>201, 'message'=>'project created'];

So far so good. This API is available and I can get the list of projects using POSTMAN Chrome Extension.

The part where I am having issues is to implement authentication. So only authenticated users are able to comsume this api. How can I setup authentication and which authentication will suit me in this scenario where my wordpress site is hosting the projects and only authenticated users will be able to create new projects on my site using the API i provided as above.

Can someone please point me to right direction?


I have manage to implement oAuth2 Authentication and will answer my question when I have a time. In case you are interesting in knowing how to do it, drop me a comment

, , Ghazanfar Mir 8 years 2015-07-27T08:50:44-05:00 0 Answers 80 views 0

Leave an answer