Skip to content

API KEY

Thomas Elvin edited this page May 23, 2019 · 7 revisions

SETUP

With API keys you are able to authenticate a user without providing that user’s password directly, instead you will use a base64 encoded string of their username and a new API key. Therefore, you need a user on GO with the required permissions to create content.

CREATING A NEW API KEY

  1. Create an user on our website here, if you don't have one already. This will provide you with a username and password.

  2. Make a request on our website, and we will provide you with an API key. Contact us here API KEY REQUEST. Use the requested API key you recieve from us in your application.

  3. Be sure to keep this API key somewhere safe, as it will not be given to you again. If you lose this API key, it cannot be obtained again. In that case, make a new API KEY REQUEST.

TESTING AN API KEY

WORDPRESS REST API

This test uses the technologies listed below, but you can use any REST API request.

  • WordPress REST API
  • cURL
  • Mac OSX or Linux
  • A Mac or Linux terminal
  • Local development environment (e.g. MAMP, XAMPP, DesktopServer, Vagrant) running on localhost
  1. Now that you have your new API key, you will need to base64 encode it using a terminal window as well as your username to use it with the REST API. The command you will use is as follows:

shell echo -n "USERNAME:API_KEY" | base64

Within this, you will replace USERNAME:API_KEY with your username and newly generated API key. For example:

shell echo -n "admin:234sd9f324p3" | base64

  1. Once your username and API key are base64 encoded, you are now able to make a simple REST API call using the terminal window to update a post. Because you are performing a POST request, you will need to authorize the request using your newly created base64 encoded access token. If authorized correctly, you will see the post title update to “New Title.”

shell curl --header "Authorization: Basic ACCESS_TOKEN" -X POST -d "title=New Title" http://LOCALHOST/wp-json/wp/v2/posts/POST_ID}

When running this command, be sure to replace ACCESS_TOKEN with your newly generated access token, LOCALHOST with the location of your local WordPress installation, and POST_ID with the ID of the post that you want to edit.

Clone this wiki locally
You can’t perform that action at this time.