You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got working code for authorizing google users. I wanted to specifically get access to some YouTube API Data, so I added the appropriate scopes to my google provider. Now when I go through the authorization process, the scopes seem to work, as the page asking me to select each one I want to provide access to appears, but now after I click continue to finish the authorization, I get an error that says "http: panic serving [::1]:42206: interface conversion: interface {} is nil, not string".
This error is happening because I am apparently making a bad request when I use the gothic.CompleteUserAuth() function in my login handler. Inside this function, at line 204 of goth/gothic/gothic.go, sess.Authorize is returning an error that says 'oauth2: "invalid_grant" "Bad Request"'. Why this is happening only when I include any scopes in my Google provider creation, I don't know, but I've provided the code for my login handler and the code for my goth session creation. This is happening with all Google scopes, not just YouTube ones, and I'm not having this issue at all with my Twitch scopes.
Any help or advice on this would be greatly appreciated, thanks.
handler_login.go:
package main
import (
"context""fmt""net/http""github.com/go-chi/chi/v5""github.com/markbates/goth/gothic"
)
func (cfg*apiConfig) handlerAuthLogin(w http.ResponseWriter, r*http.Request) {
provider:=chi.URLParam(r, "provider")
r=r.WithContext(context.WithValue(context.Background(), "provider", provider))
ifuser, err:=gothic.CompleteUserAuth(w, r); err==nil {
http.Redirect(w, r, "http://localhost:5173", http.StatusFound)
cfg.createUser(w, r, user)
return
} else {
fmt.Println("it is time to begin logging in!")
gothic.BeginAuthHandler(w, r)
}
}
The text was updated successfully, but these errors were encountered:
MeirionL
changed the title
Google authorization not working when I include scopes
Google authorization claiming "Bad Request" when I include scopes
Dec 10, 2023
Func86
added a commit
to Func86/goth
that referenced
this issue
Jun 22, 2024
I've got working code for authorizing google users. I wanted to specifically get access to some YouTube API Data, so I added the appropriate scopes to my google provider. Now when I go through the authorization process, the scopes seem to work, as the page asking me to select each one I want to provide access to appears, but now after I click continue to finish the authorization, I get an error that says "http: panic serving [::1]:42206: interface conversion: interface {} is nil, not string".
This error is happening because I am apparently making a bad request when I use the gothic.CompleteUserAuth() function in my login handler. Inside this function, at line 204 of goth/gothic/gothic.go, sess.Authorize is returning an error that says 'oauth2: "invalid_grant" "Bad Request"'. Why this is happening only when I include any scopes in my Google provider creation, I don't know, but I've provided the code for my login handler and the code for my goth session creation. This is happening with all Google scopes, not just YouTube ones, and I'm not having this issue at all with my Twitch scopes.
Any help or advice on this would be greatly appreciated, thanks.
handler_login.go:
auth.go:
The text was updated successfully, but these errors were encountered: