Spotify API "Request failed with status code 403"

24 views Asked by At

I'm currently working on a React Native with Expo Go application that tracks Spotify stats using the Spotify API. I was able to successfully set up the authentication process on my iPhone, however, when someone else tries to log in, the app returns an error message stating "Request failed with status code 403".

I added an error handler and discovered that when others try to log in, the app returns the following error:

"ERROR Forbidden: Insufficient permissions or rate limit exceeded".

I reviewed the Spotify for Developers documentation, but haven't found a solution yet. I would appreciate any help/advice.

useEffect(() => {
    if (token) {
      axios("https://api.spotify.com/v1/me/top/tracks?time_range=short_term", {
        method: "GET",
        headers: {
          Accept: "application/json",
          "Content-Type": "application/json",
          Authorization: `Bearer ${token}`,
        },
      })
        .then((response) => {
          dispatch(songAction.addTopSongs(response.data.items));
          dispatch(tokenAction.addToken(token));
          navigation.replace("Home", { token: token });
        })
        .catch((error) => {
          if (error.response && error.response.status === 403) {
            // Handle 403 error (Forbidden)
            console.error("Forbidden: Insufficient permissions or rate limit exceeded.");
          } else {
            console.error("Error:", error.message);
          }
        });
    }
  }, [token, dispatch, navigation]);

0

There are 0 answers