#605·goth

Redirect URL not working for GitHub provider

Author: kathrindcCreated Apr 23, 2025Updated Apr 23, 2025

Hi there, I'm trying to get GitHub authentication working at the moment, but I'm running into an issue where the provider is seemingly not setting the redirect_uri query parameter when redirecting to GitHub's authorize endpoint. I think I am configuring it correctly and I double-checked that my redirect URL is set to localhost, but I still get redirected to the prod domain.

go
var (
	ghClientId     = os.Getenv("OAUTH_GITHUB_CLIENT_ID")
	ghClientSecret = os.Getenv("OAUTH_GITHUB_CLIENT_SECRET")
	ghRedirectUrl  = os.Getenv("OAUTH_GITHUB_REDIRECT_URL")
)

func main() {
	// ...

	goth.UseProviders(
		github.New(ghClientId, ghClientSecret, ghRedirectUrl, "email"),
	)

	// ...
}

When I check the redirects in my browser's developer tools it's visible that the redirect_uri parameter is missing entirely.

Image