Skip to content
  • Why WPGetAPI?
  • Examples
  • Pricing
  • Plugins
    • PRO Plugin
    • API to Posts Plugin
    • OAuth 2.0 Plugin
  • Docs
  • Support
    • Frequently Asked Questions
    • Feature Request
    • Support Ticket
  • account_circle
PRO Plugin
Howdy! How can we help you?
  • Introduction

    • Quick Start
    • Frequently Asked Questions
    • Will this work with my API?
    • Understanding API docs
    • Step by Step Example
  • Setup

    • Setup Page
    • Endpoint Page
    • Parameters - Query String
    • Parameters - Headers
    • Parameters - Body POST
    • Shortcode
    • Template Tag
    • Gutenberg Block
  • Connecting your API

    • API Key in Headers
    • API Key in Query String
    • Authentication & Authorization
  • Output API Data

    • Format API to HTML
    • Format API to HTML Table
    • Format API to Image Gallery
    • Format JSON Data
  • Integrations

    • Send form data to API
    • WPForms to API
    • Gravity Forms to API
    • Contact Form 7 to API
    • WooCommerce to API
    • WooCommerce API Product Sync
    • wpDataTables to API
    • Connect WordPress to OpenAI
    • Connect RapidAPI to WordPress
    • Connect Zoho CRM to WordPress
    • Page Builders (Elementor, DIVI)
    • Formidable Forms to API
    • Elementor Form to API
    • JetFormBuilder to API
    • Fluent Forms to API
    • WS Form to API
    • Ninja Tables to API
    • Easy Digital Downloads(EDD) API Product Sync
    • Ultimate Member Forms to API
  • Tips & Tricks

    • Filters & Action Hooks
    • Code Snippets Plugin
    • Troubleshooting
    • Code Snippets
  • PRO Plugin

    • Installation
    • Actions
    • Tokens
    • Caching
    • Nested data
    • Chaining API calls
    • Dynamic Variables
    • Format API to HTML
    • Call API on user registration
    • Using AJAX to trigger API call
    • Base64 Encoding
    • Licensing
    • Filters & Action Hooks
  • OAuth 2.0 Plugin

    • Installation
    • How it works
    • Grant Type - Client Credentials
    • Grant Type - Authorization Code
    • Licensing
  • API to Posts Plugin

    • Installation
    • Getting Started
    • Multiple Endpoints
    • Mapping Fields
    • Filters & Action Hooks
    • Pagination
This feature is only available in the OAuth 2.0 Authorization Plugin.

This article will show you how to setup OAuth 2.0 Authorization using the Grant Type of Client Credentials.

We won’t be going into great depths about what each feature is, we will simply look at how to set it up OAuth 2.0 with our plugin. Here is an article explaining what OAuth 2.0 is if you want to learn more about it before we get started. 

Getting Started

For this article, we are going to connect to the Amadeus Self-Service APIs and retrieve the Flight Offers Price from Amadeus. Anyone can create a free Amadeus test account to follow along.

  • The docs for creating an account and getting the access keys from Amadeus are here.
  • The docs for the Flight Offers Price can be found here.

Step 1 – Register an application

The first step with any OAuth 2.0 authorization is to register an app.

Most services will have a ‘Developers Console’ or ‘App Console’ where you can register your apps. Here is a link to the Amadeus Developer Console where you will be asked to log in or register and once logged in,  Go to My Self-Service Workspace and click on Create New App button.

 

After clicking Create, you will then get the API Key and the API Secret, which we will use in the next step.

Step 2 – Configure settings in WPGetAPI 

We now need to add all of our app details and some Amadeus API details to our OAuth 2.0 settings page within the WordPress admin – the page looks something like the image below.

The fields are:

  • Client ID – this is the API Key from our app
  • Client Secret – the API Secret from our app
  • Access Token URL – https://test.api.amadeus.com/v1/security/oauth2/token
  • Client Authentication
    • This is the method that we use to send data (in the background) to the Access Token URL above. Your API docs will tell you which method to use and in our case, Amadeus will Send in the body
  • Scope
    • For the Scope, we need to go searching a bit here. We need to look at the endpoints that we are going to eventually use and get the scope value from there.
    • Here in Amadeus, there is no scope option so it should be blank.

Step 3 – Authorize our application

With our details saved, we will now see the Get Token button become active as shown below and we can also see that we have ‘No token yet’.

If we are happy that all the details we have entered are correct, we can click the button where the page is refreshed and the token is generated. We can now make our API call with the use of wpgetapi_oauth_token keyword in our Endpoint setup page.

Step 4 – Using the token to make API calls

We have a token now and we want to use our token to start making API calls, but we don’t want to actually copy the token and use it anywhere with WPGetAPI.

Access tokens have a limited life and usually expire within minutes or hours of being created. So if we add our token to any API calls, it will not work after the token expiry time. Tokens need to be refreshed when they expire, and this is what our OAuth 2.0 plugin does automatically in the background.

So instead of adding the actual token that we have received, we need to use the keyword ‘wpgetapi_oauth_token’ instead. This keyword basically tells our OAuth 2.0 plugin where we need the token. The plugin will see this keyword and replace the keyword with our refreshed and up-to-date token.

Looking at the Amadeus API Docs, it shows us that the token needs to be used in the header. Some API’s might also use the token in the query string.

 

Authorization: Bearer d92d4xxxxxxxxxxxxxxxxxx15f52

But we will use the keyword ‘wpgetapi_oauth_token’ instead of the token, so that it would now look like this:

Authorization: Bearer wpgetapi_oauth_token

Now when we setup our endpoint, we just need to add Authorization within the Name field and Bearer wpgetapi_oauth_token within the Value field of our headers.

You can now use the template tag or the shortcode to call your API endpoints.

 

On this page
contact_support

Still not sure?

APIs can be daunting and sometimes downright confusing.

But we are here to help! Our support is amazing and we can assist you with any setup required and ensure your API integrations are a success!

Ask Us Anything

Connect your WordPress website to external APIs without writing a single line of code. Send data from WordPress to your API or display data from your API within WordPress.

Support

  • Documentation
  • Support Ticket
  • Refund Policy
  • Contact Us
  • About Us
  • Affiliates

Articles

  • Quick Start Guide
  • WooCommerce Orders to API
  • WooCommerce API Products Sync
  • Contact Form 7 to API
  • WPForms to API
  • Gravity Forms to API
  • WordPress to RapidAPI

WordPress API Plugins

  • Free WPGetAPI Plugin
  • PRO Plugin
  • API to Posts Plugin Plugin
  • OAuth 2.0 Authorization Plugin

© 2025 WPGetAPI. All Rights Reserved.

"*" indicates required fields

Name*
This field is for validation purposes and should be left unchanged.