API Authentication¶
Every request made to the REST API (GET or POST) must be authenticated using HTTP basic access authentication. The credentials used in this process are your API’s account_id
and auth_token
. To authenticate, every API request must contain a Authorization
HTTP header. The value of the header should have the structure Basic <auth_string>
. Where <auth_string>
is the following base64 encoded string account_id:auth_token
.
Authenticating Requests¶
Most standard language packages contain built-in functions to do HTTP basic access authentication. Here some examples of how to list applications with proper authentication.
Curl¶
curl -u ACCOUNT_ID:AUTH_TOKEN -X GET https://api.gridspace.com/v0/applications
Ruby¶
require 'uri'
require 'net/http'
ACCOUNT_ID = "test"
AUTH_TOKEN = "test_secret"
uri = URI("https://api.gridspace.com/v0/applications")
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})
# Constructs the Authorization header
req.basic_auth(ACCOUNT_ID, AUTH_TOKEN)
...
Python¶
import requests
ACCOUNT_ID = "test"
AUTH_TOKEN = "test_secret"
url = "https://api.gridspace.com/v0/applications"
r = requests.get(url, auth=(ACCOUNT_ID, AUTH_TOKEN))