Hey Figma friends,
I’ve been experimenting with the Figma REST API for an app. I have a prototype that works well with my Personal Access Token. But now I’m trying to build out the entire OAuth2 flow.
I can see the access_token
and other attributes from the response after making this POST request:
POST https://www.figma.com/api/oauth/token?
client_id=:client_id&
client_secret=:client_secret&
redirect_uri=:callback&
code=:code&
grant_type=authorization_code
{
"access_token": <TOKEN>,
"expires_in": <EXPIRATION (in seconds)>,
"refresh_token": <REFRESH TOKEN>
}
But when I finally make this call:
headers = {"content-type": "application/json", "Accept-Charset": "UTF-8", 'X-FIGMA-TOKEN': accessToken}
fileURL = 'https://api.figma.com/v1/files/' + figmaFileKey
fileResponse = requests.get(fileURL, headers=headers)
I get a 403 Invalid token as the response.
Any idea what I could be doing wrong? Thanks for your help.