Closed yanlkm closed 1 month ago
Hi @yanlkm, I am using init(), and it is working for me, Here is code sample
func init() {
goth.UseProviders(google.New("xxxxxxx", "xxxxxxx", "http://localhost:8080/v1/api/auth/google/callback", "email", "profile"))
}
func BeginGoogleAuth(c *gin.Context) {
q := c.Request.URL.Query()
q.Add("provider", "google")
c.Request.URL.RawQuery = q.Encode()
gothic.BeginAuthHandler(c.Writer, c.Request)
}
You can also create a function to add the provider to the context like this.
func addProviderToContext(ctx *gin.Context, provider string) *http.Request {
return ctx.Request.WithContext(context.WithValue(ctx.Request.Context(), "provider", provider))
}
Then use it on callback like so.
ctx.Request = addProviderToContext(ctx, prov)
Yes, the above suggestions are what I use too.
Hello, I'm trying to use the goth oauth for github authentification, Im using Gin Router. Whatever I'm trying to do, I got the same error of provider missing, Can someone help me ? Thank you
Here is my router code :