Hello all - I’m trying to get my development environment set up to build some desktop utilities to modify LucidChart documents. I’m attempting my first API call to the documents endpoint and getting a 403 response. Any help would be greatly appreciated - and sorry for the long post.
Here’s what I’ve done so far:
- Created my document in LucidChart, so I am the owner of it. Grabbed the document ID from the URL (hopefully that’s the right one?)
- In the Lucid Developer Portal, I created an application, created the OAuth 2.0 client, generated my client ID and Client secret, and registered the Lucid Test redirect URI using my client ID.
- I am using VS Code and Python, and have leveraged some of your sample code from the documentation to get the authentication and token refreshing working, storing the access token locally for use until expired. Seems to be working great so far!
- Since I’m building against just the console right now, I temporarily have the script launch a web browser for the OAuth process, and then it waits for me to manually copy and paste the verification code from the redirect page back into my app prompt. (fancy fancy I know!)
-
I threw a bit of the kitchen sink in with the Scopes:
"lucidchart.document.app lucidchart.document.content offline_access user.profile"
params = {
'response_type': 'code',
'client_id': self.client_id,
'scope': self.scopes,
'redirect_uri': self.redirect_uri }
- Now that I have an access token, here’s my attempt to get document information. This is where I’m receiving a 403 response.
def get_document(access_token, document_id):
# The API endpoint to get information about the LucidChart document
url = f'https://api.lucid.co/documents/{document_id}'
# Required headers
headers = {
'Authorization': f'Bearer {access_token}',
'Lucid-Api-Version': '1',
'Accept': 'application/json'}
# Make the GET request
response = requests.get(url, headers=headers)
# Check if the request was successful
if response.status_code == 200:
# Parse the response JSON and work with the data
document_data = response.json()
return document_data
else:
print(f'Failed to retrieve document data: {response.status_code}')
return None
Thanks in advance!
Matt