Skip to main content
POST
/
oauth2
/
token
/
Get Token
curl --request POST \
  --url https://sandbox.elationemr.com/api/2.0/oauth2/token/ \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data grant_type=client_credentials \
  --data 'client_id=<string>' \
  --data 'client_secret=<string>' \
  --data 'scope=<string>'
import requests

url = "https://sandbox.elationemr.com/api/2.0/oauth2/token/"

payload = {
"grant_type": "client_credentials",
"client_id": "<string>",
"client_secret": "<string>",
"scope": "<string>"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}

response = requests.post(url, data=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
grant_type: 'client_credentials',
client_id: '<string>',
client_secret: '<string>',
scope: '<string>'
})
};

fetch('https://sandbox.elationemr.com/api/2.0/oauth2/token/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.elationemr.com/api/2.0/oauth2/token/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=client_credentials&client_id=%3Cstring%3E&client_secret=%3Cstring%3E&scope=%3Cstring%3E",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://sandbox.elationemr.com/api/2.0/oauth2/token/"

payload := strings.NewReader("grant_type=client_credentials&client_id=%3Cstring%3E&client_secret=%3Cstring%3E&scope=%3Cstring%3E")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://sandbox.elationemr.com/api/2.0/oauth2/token/")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=client_credentials&client_id=%3Cstring%3E&client_secret=%3Cstring%3E&scope=%3Cstring%3E")
.asString();
require 'uri'
require 'net/http'

url = URI("https://sandbox.elationemr.com/api/2.0/oauth2/token/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=client_credentials&client_id=%3Cstring%3E&client_secret=%3Cstring%3E&scope=%3Cstring%3E"

response = http.request(request)
puts response.read_body
"{\n  \"access_token\": \"TyEPKw8fVGRKpCBa81ygwjCLXDNIAm\",\n  \"token_type\": \"Bearer\",\n  \"expires_in\": 36000,\n  \"refresh_token\": \"44fpQdEzMP36klMm8xrg8CuD75jPnF\",\n  \"scope\": \"...\"\n}"
"{\"error\": \"invalid_client\"}"
We currently support one OAuth2 grant type: Client Credentials.

Client Credentials

You can exchange your client_id and client_secret for an access token directly.

Headers

Content-type
string
default:application/x-www-form-urlencoded

Body

application/x-www-form-urlencoded
grant_type
string
default:client_credentials
required

We currently only support client_credentials grant type.

client_id
string

Client ID that was supplied to you with your credentials

client_secret
string

Client Secret that was provided to you with your credentials

scope
string

Currently in closed Beta for select customers. Optional. Space-separated list of scopes to request. If omitted, defaults to apiv2 which grants the token access to all API resources.

Response

200

access_token
string
Example:

"TyEPKw8fVGRKpCBa81ygwjCLXDNIAm"

token_type
string
Example:

"Bearer"

expires_in
integer
default:0
Example:

36000

refresh_token
string
Example:

"44fpQdEzMP36klMm8xrg8CuD75jPnF"

scope
string
Example:

"..."