Skip to main content
Question

OAuth Token | 403: invalid token | Typescript/React

  • January 16, 2025
  • 2 replies
  • 116 views

Adam Sivins

I’m seeing some unexpected behavior with an OAuth token and it’s requests. 

I’ve a Token fetch setup that works as expected. But after having recived said token and go to make API requests with it, none of them return with good data. They all return with an error of 430: invalid token. 

Below is a snippet of my user `/me` request. It returns a a 403 with a fresh token

const fetchUserData = async (token: string) => {
    fetch(`https://api.figma.com/v1/me`, {
      headers: {
        'Authorization': `Bearer ${token}`,
      }
    })
    .then(response => response.json())
    .then(response => {
      if (response.status === 403) console.log(`${response.status}: ${response.err}`)
      else {
        console.log(`Logged into Figma as ${response.handle}`);
        setUserData(response);
      }
    })
    .catch((error) => {
      throw new Error (`API Request Failure: ${error}`);
    });
  };

 

2 replies

Adam Sivins
  • Author
  • New Member
  • 2 replies
  • January 22, 2025

UPDATE: 

This issue is intermittent. I have gotten a positive response to this code. I’ve adjusted it for better error handling. 

const fetchUserData = async (accessToken: string) => {
    fetch(`https://api.figma.com/v1/me`, {
      headers: {
        'Authorization': `Bearer ${accessToken}`,
        'Content-type': 'application/json'
      }
    })
    .then(response => response.json())
    .then(response => {
      if (response.status >= 400) console.log(`${response.status}: ${response.err}`)
      else {
        console.log(`Logged into Figma as ${response.handle}`);
        setUserData(response);
      }
    })
    .catch((error) => {
      console.error('API Request Failure:', error);
      throw new Error (`API Request Failure: ${error}`);
    });
  };

 


Adam Sivins
  • Author
  • New Member
  • 2 replies
  • January 23, 2025

To clarify: 

My original issue persists. Without altering the request code, I most commonly get a 403 while requesting data from the Rest API. Above is one of the requests returning said error. 
 

Also, when requesting a new OAuth Token, I have a 50/50 chance of getting a token that results in the issue above, but, also get a 429 or 400.


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