Skip to content

Commit

Permalink
fix: set accept header for GitLab (#2998)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jan 4, 2023
1 parent 8fbb1bb commit e892113
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions selfservice/strategy/oidc/provider_gitlab.go
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 e892113

Please sign in to comment.