André Silveira
André Silveira

Reputation: 23

Unable to access Figma API token with a HTTP request

i am trying to acess the figma API using my personal token, but once i make the request it sends a response with the 403 status (forbidden), can someone help me ?

I generated a token: My token

I am making the request to the following url: 'https://api.figma.com/v1/files/${mytoken}';

The status code is the following: 403

What is wrong with my code? is the url wrong ?

    fetch('https://api.figma.com/v1/mytoken').then((response) => {
        console.log(response)

})

Status code: 403 Forbidden

Upvotes: 1

Views: 1630

Answers (1)

Nils Kähler
Nils Kähler

Reputation: 3001

According to figma authentication documentation you should add the token to the header of the request.

X-Figma-Token: *YOUR TOKEN*
fetch('https://api.figma.com/v1/files/...', {
        method: 'GET',
        headers: {
            'X-Figma-Token': 'your-figma-token',
        },
    })
    .then(response => response.json())
    .then(response => console.log(response))
    .catch(err => console.error(err));

Upvotes: 0

Related Questions