# Make sure you have Python installed from https://www.python.org/
# Copy this code and save it to a file called authentication_example.py
# Install dependencies
# pip install requests
import requests
import json
# Fill ALL the below parameters with proper values
CLIENT_ID = "REPLACE-ME-WITH-CLIENT-ID" # This is the client ID
CLIENT_SECRET = "REPLACE-ME-WITH-CLIENT-SECRET" # This is the client secret
SCOPE = "REPLACE-ME-WITH-SCOPE" # This is the scope (looks like url)
SUBSCRIPTION_KEY = "REPLACE-ME-WITH-SUBSCRIPTION-KEY" # This is the subscription key
ORGANIZATION_NUMBER = "REPLACE-ME-WITH-ORGANIZATION-NUMBER" # This is the organization number
# Request new Access token. No need for changing anything below
print("Requesting access token from identity provider")
token_response = requests.post("https://id.talenom.com/api/b2b/oauth2/v1.0/token",
data="grant_type=client_credentials&client_id=" + CLIENT_ID + "&client_secret=" + CLIENT_SECRET + "&scope=" + SCOPE,
headers={"Content-Type": "application/x-www-form-urlencoded"})
access_token = token_response.json()["access_token"]
print("This is your access token:", access_token)
# ApiUrl is the actual url to make the GET request. In this example we will call organization-api and get basic organization information for the organization assigned in the parameters.
api_url = "https://apim.talenom.com/organization/v1/organization-info/" + ORGANIZATION_NUMBER
headers = {
"Authorization": "Bearer " + access_token,
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": SUBSCRIPTION_KEY
}
# Making the request into API
response = requests.get(api_url, headers=headers)
print(response.json())
# Run with: python authentication_example.py