Skip to content

Commit

Permalink
fix: set accept header for GitLab (ory#2998)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored and CNLHC committed May 16, 2023
1 parent 19fa095 commit 5c7a7c7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions selfservice/strategy/oidc/provider_gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package oidc
import (
"context"
"encoding/json"
"net/http"
"net/url"
"path"

Expand Down Expand Up @@ -85,12 +86,17 @@ func (g *ProviderGitLab) Claims(ctx context.Context, exchange *oauth2.Token, que
return nil, errors.WithStack(herodot.ErrInternalServerError.WithReasonf("%s", err))
}

req.Header.Set("Accept", "application/json")
resp, err := client.Do(req)
if err != nil {
return nil, errors.WithStack(herodot.ErrInternalServerError.WithReasonf("%s", err))
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return nil, errors.WithStack(herodot.ErrInternalServerError.WithReasonf("Expected the GitLab userinfo endpoint to return a 200 OK response but got %d instead.", resp.StatusCode))
}

var claims Claims
if err := json.NewDecoder(resp.Body).Decode(&claims); err != nil {
return nil, errors.WithStack(herodot.ErrInternalServerError.WithReasonf("%s", err))
Expand Down

0 comments on commit 5c7a7c7

Please sign in to comment.