Skip to main content
Solved

Figma API Help

  • February 8, 2021
  • 2 replies
  • 3252 views

beekay

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.

Best answer by Gleb

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

View original

2 replies

Gleb
  • Power Member
  • 4706 replies
  • Answer
  • February 8, 2021

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


beekay
  • Author
  • 1 reply
  • February 9, 2021

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings