Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't create a new client... What am i doing wrong? #208

Open
JulietteDestang opened this issue Nov 5, 2022 · 0 comments
Open

can't create a new client... What am i doing wrong? #208

JulietteDestang opened this issue Nov 5, 2022 · 0 comments

Comments

@JulietteDestang
Copy link

JulietteDestang commented Nov 5, 2022

hi guys, thanks for this package!

i'm trying to create an oAuth for spotify, but i have an "infinite loop" in the callback

func AuthSpotify(w http.ResponseWriter, r *http.Request) {
	tok, err := auth.Token(r.Context(), state, r)
	if err != nil {
		http.Error(w, "Couldn't get token", http.StatusForbidden)
		log.Fatal(err)
	}
	if st := r.FormValue("state"); st != state {
		http.NotFound(w, r)
		log.Fatalf("State mismatch: %s != %s\n", st, state)
	}


	client := spotify.New(auth.Client(r.Context(), tok))
	// infinite loop ^^^
	
	w.Header().Set("Content-Type", "text/html")
	fmt.Fprintf(w, "Login Completed!")
	ch <- client
}

i send the url to my front with this function:

func GetSpotifyUrl(w http.ResponseWriter, r *http.Request) {
	fmt.Println("ok")
	url := auth.AuthURL(state)
	res, _ := json.Marshal(url)
	w.WriteHeader(http.StatusOK)
	w.Write(res)

}

the redirect is working and call my callback, but i'm stuck in this callback function :/

can you help me? thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant