markbates / markbates/goth

Redirect URL not working for GitHub provider

Open
#605 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
6.6k
Forks
631
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the GitHub provider configured through github.New and trace how its authorization URL is built. Reproduce the redirect with browser developer tools, then verify that the configured localhost URL is included as the redirect_uri parameter in the GitHub authorize request.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.