Apple auth with scopes not working correct
When using apple auth scopes "email", "name" the current provided not parse POST response for get "first_name" and "last_name".
I found why :
Here: https://github.com/markbates/goth/blob/dcd837795bb225182b7ca6a6ac86ca4e79ace5ec/gothic/gothic.go#L199
We check that params.Encode() == "",
But in the comment it is said
https://github.com/markbates/goth/blob/dcd837795bb225182b7ca6a6ac86ca4e79ace5ec/gothic/gothic.go#L157
And the provider is never removed from the params, making the code that use the form unreachable.
I'll try to push a PR but I might not have time for this
As a workaround I passed a new context with the provider in there instead of passing it through the params.
Like so:
func appleCallback(res http.ResponseWriter, req *http.Request) {
ctx := context.WithValue(req.Context(), "provider", "apple")
user, err := gothic.CompleteUserAuth(res, req.WithContext(ctx))
if err != nil {
fmt.Fprintln(res, err)
return
}
t, _ := template.New("foo").Parse(userTemplate)
t.Execute(res, user)
}
p.Post("/oauth/apple", appleCallback)