Screenshot WOW SAVE 20% on the All Access Bundle. Use "OAUTH20OFF" at checkout.
GET DEAL
3rd Party Integration

How to Authenticate with WP REST API

Published: October 4, 2018 | Updated: January 1st, 2020
  1. Home
  2. Docs
  3. How To
  4. How to Authenticate with WP REST API

Overview

This article will cover how to use WP OAuth Server and OAuth2 to make authenticated requests to WP REST API. 

Things You Need to Authenticate

The first thing to do is download WP OAuth Server from your account. If you do not have WP OAuth Server, you will need to download it by visiting https://wp-oauth.com/downloads/wp-oauth-server/.

Create a Client

With WP OAuth Server installed we will see a link in the main navigation label “OAuth Server”. By hovering over this link we will be presented the link to create a new client. Let’s give our client a name and select the grant type “User Credentials”. Once we have created our client, we will need to make a copy of the “Client ID” and “Client Secret“. We will need to use this information to gain an access token later.

Obtaining an Access Token

How we obtain an access token is dependent on our project. In this article, we will be obtaining an access token using the “User Credentials” grant type. You will need to download “POSTMAN“. Once you have Postman installed, we will need to start configuring it.

Check out this article for details using Postman.

Using the Access Token

Now that we have an access token, we can use this token to make authorized calls to the WP REST API. There are two ways that we can pass an access token to the API.

Example

For simplicity of this article lets use the URL method to send our access token. Below is a simple call to the REST API to retrieve post revisions.

HTTP 1.1 GET
https://{server_url}/wp-json/posts/{post_id}/revisions?access_token={access_token}

Success

If you receive an error about not being authorized to make the call, ensure that you are logged out of WordPress.

If you have any questions, please submit a support request.

Icon