Skip to content

Authentication

Authentication token is needed to use the whitson external API. Request credentials from support@whitson.com. Use the received credentials to request authentication token.

cURL Example

1
2
3
4
5
# replace CLIENT with the CLIENT_NAME you received
curl --request POST \
  --url https://whitson.eu.auth0.com/oauth/token \
  --header 'content-type: application/json' \
  --data '{"client_id":CLIENT_ID,"client_secret":CLIENT_SECRET,"audience":"https://CLIENT.whitson.com/","grant_type":"client_credentials"}'

Python Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
import http.client
import json

# To fill
CLIENT = "<CLIENT_NAME>"
CLIENT_ID = "CCC"
CLIENT_SECRET = "DDD"


conn = http.client.HTTPSConnection("whitson.eu.auth0.com")
payload = {
    "client_id": CLIENT_ID,
    "client_secret": CLIENT_SECRET,
    "audience": f"https://{CLIENT}.whitson.com/",
    "grant_type": "client_credentials",
}

headers = {"content-type": "application/json"}
conn.request("POST", "/oauth/token", json.dumps(payload), headers)
res = conn.getresponse()
data = res.read()
access_token = json.loads(data.decode("utf-8")).get("access_token")
# save/export this access token for the work session

base_url = f"https://{CLIENT}.whitson.com/api-external/v1/"
response = requests.get(
    base_url + "wells",
    params={"project_id": 1},
    headers={
        "content-type": "application/json",
        "Authorization": f"Bearer {access_token}",
    },
)

print(response)