no provider for openid-connect exists
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.6k
- Forks
- 631
- PR merge metrics
- No merged PRs in 30d
Description
I keep getting `no provider for openid-connect exists` when I try to connect to local keycloak.
```
package main
import (
"fmt"
"html/template"
"net/http"
"github.com/markbates/goth"
"github.com/markbates/goth/gothic"
"github.com/markbates/goth/providers/openidConnect"
)
func main() {
openidConnect, _ := openidConnect.New("idp", "SECRET", "http://localhost:7080/realms/svcs/.well-known/openid-configuration", "http://localhost:8080/auth/openid-connect/callback")
if openidConnect != nil {
goth.UseProviders(openidConnect)
}
// Note that the redirect URL is different here than in your original code.
//goth.UseProviders(oid)
r := http.NewServeMux()
r.HandleFunc("GET /auth/openid-connect/callback", func(res http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
q.Add("provider", "openid-connect")
r.URL.RawQuery = q.Encode()
user, err := gothic.CompleteUserAuth(res, r)
if err != nil {
fmt.Println("error ", err)
}
t, _ := template.New("foo").Parse(userTemplate)
t.Execute(res, user)
})
r.HandleFunc("GET /auth/openid-connect", handleAuth)
r.HandleFunc("/", func(writer http.ResponseWriter, r *http.Request) {
t, _ := template.New("foo").Parse(indexTemplate)
t.Execute(writer, nil)
})
http.ListenAndServe(":8080", r)
}
func handleAuth(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
q.Add("provider", "openid-connect")
r.URL.RawQuery = q.Encode()
gothic.BeginAuthHandler(w, r)
}
var indexTemplate = `
`
var userTemplate = `
Name: {{.Name}}
Email: {{.Email}}
NickName: {{.NickName}}
Location: {{.Location}}
AvatarURL: {{.AvatarURL}}
Description: {{.Description}}
UserID: {{.UserID}}
AccessToken: {{.AccessToken}}
`
```
Keycloak is running and the client is set. What am missing?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the shown openidConnect.New call and inspect its returned error before goth.UseProviders is invoked. Trace how gothic.BeginAuthHandler and CompleteUserAuth look up the provider named in the request. Done means identifying the configuration or registration mismatch that causes the reported provider error and confirming the example can complete authentication.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100