How to authenticate private API token in Python to access RightSignature

Viewed 22

I'm new to Python and attempting to write a script that connects to RightSignature API using a private API Token. The documentation says to use the Private API Token, along with the Client ID and Client Secret to sign API requests. This should be returning information about the authenticated RightSignature User. All the private info is stored in a .env file.

Here's what I have so far...

from flask import Flask, request, jsonify
import os
import requests
from dotenv import load_dotenv


API_HOST = "api.rightsignature.com"

load_dotenv()
API_TOKEN = os.environ.get("API_TOKEN")
CLIENT_ID = os.environ.get("client_id")
CLIENT_SECRET = os.environ.get("client_secret")

headers = {
    "private-api-key" : API_TOKEN,
    "client-id" : CLIENT_ID,
    "client-secret" :CLIENT_SECRET

}

url = "https://{}/public/v2/me".format(API_HOST)

response = requests.get(url, headers=headers)
print(response.text) 

I get the following error if I run this...

{"error":"invalid_token","error_description":null}

Any help would be greatly appreciated!!!

0 Answers
Related