Announcements
Hey folks! Some of you might see that your episodes are removed/ not being ingested by Spotify. More info about this can be found here.

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

400 bad requests error every time user atuh is provided

400 bad requests error every time user atuh is provided

My Question or Issue

I'm getting Bad Request errors every time I try to make a call with the code generated by giving clientID and clientSecret.
I do get a new code every time I log in with Spotify and authorize access and get redirected to the new page, and then right after redirected to the page when an error is caught. I'm using the spotify-web-api-node package module.
If you want/ can take a look at my code I can provide it.

Reply
3 Replies

Your code is necessary to diagnose and fix your problem.

import { useEffect, useState } from "react";
import axios from "axios";

export default function useAuth(code) {
    const [accessToken, setAccessToken] = useState();
    const [refreshToken, setRefreshToken] = useState();
    const [expiresInToken, setExpiresIn] = useState();

    useEffect(() => {
        axios
            .post("http://localhost:3001/login", {
                code : code
            })
            .then((res) => {
                window.history.pushState({}, null, "/");
                console.log(res.data);
            })
            .catch((err) => {
                window.location = "/";
                console.log(err)
            });
    }, [code]);
}

 

 

axios
    .post("http://localhost:3001/login", {
        code : code
    })​

 

 

 


This is not a valid request for the authorization process. Delete this code and start over. You must implement one of the authorization flows as described in the authorization guide.

Suggested posts