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'm having an issue where goth is not pulling the value of the {provider} parameter from my chi router, but it does so with the gorilla/pat router. Here is a code sample:
func main(){
router := chi.NewRouter()
patRouter := pat.New()
store := sessions.NewCookieStore([]byte(os.Getenv("JWT_SECRET")))
store.MaxAge(5000)
store.Options.Path = "/"
store.Options.HttpOnly = true
store.Options.Secure = true
gothic.Store = store
goth.UseProviders(
google.New(os.Getenv("CLIENT_ID"), os.Getenv("CLIENT_SECRET"), "http://localhost:8080/auth/google/callback", "email", "profile"),
)
router.Use(newCors.Handler)
patRouter.Use(newCors.Handler)
router.Get("/auth/{provider}", func(res http.ResponseWriter, req *http.Request) {
url, err := gothic.GetAuthURL(res, req)
fmt.Println("url:", req.URL.Query())//Here, the map is empty.
fmt.Println("err:", err)//Also, the err returned is " you must select a provider".
res.Write([]byte(url))
})
patRouter.Get("/auth/{provider}", func(res http.ResponseWriter, req *http.Request) {
url, err := gothic.GetAuthURL(res, req)
fmt.Println("url:", req.URL.Query())//Here on the other hand, the map is populated as such -> map[:provider:[google]]
fmt.Println("err:", err)//err is nil here.
res.Write([]byte(url))
})
go http.ListenAndServe(":9090", patRouter)
http.ListenAndServe(":8080", router)
}
I'm testing this from a react front using the following code:
const responsePat = await fetch("http://localhost:9090/auth/google")
const resultPat = await responsePat.text()
console.log(resultPat)//Url is returned here
const responseChi = await fetch("http://localhost:8080/auth/google")
const resultChi = await responseChi.text()
console.log(resultChi)//Empty string is returned here.
Chi and Pat both use net/http, so I'm not sure why the url parameter is not being read by the gothic.GetAuthURL(res, req) function. Am I doing anything wrong?
The text was updated successfully, but these errors were encountered:
I'm having an issue where goth is not pulling the value of the
{provider}
parameter from my chi router, but it does so with thegorilla/pat
router. Here is a code sample:I'm testing this from a react front using the following code:
Chi and Pat both use
net/http
, so I'm not sure why the url parameter is not being read by thegothic.GetAuthURL(res, req)
function. Am I doing anything wrong?The text was updated successfully, but these errors were encountered: