Figma Support Forum

Figma API Help

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.

I’m pretty sure for Oauth flow you need to use Bearer token, not X-FIGMA-TOKEN. I don’t remember as I did it a long time ago but check out this project’s code, it was working the last time I checked: https://glitch.com/edit/#!/figma-to-gif?path=server.js%3A111%3A61

Gah, can’t believe I missed that. That was it! Thanks for your help.