Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Larwig <[email protected]>
  • Loading branch information
bitfehler and tuunit authored Jan 3, 2024
1 parent 92e1fca commit cd5fbef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions providers/srht.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ func (p *SourceHutProvider) EnrichSession(ctx context.Context, s *sessions.Sessi
WithMethod("POST").
SetHeader("Content-Type", "application/json").
SetHeader("Authorization", "Bearer "+s.AccessToken).
WithBody(strings.NewReader("{\"query\": \"{ me { username, email } }\"}")).
WithBody(bytes.NewBufferString(`{"query": "{ me { username, email } }"}`)).
Do().
UnmarshalSimpleJSON()
if err != nil {
logger.Errorf("failed making request %v", err)
return err
}

email, err := json.Get("data").Get("me").Get("email").String()
email, err := json.GetPath("data", "me", "email").String()
if err != nil {
return fmt.Errorf("unable to extract email from userinfo endpoint: %v", err)
}
s.Email = email

username, err := json.Get("data").Get("me").Get("username").String()
username, err := json.GetPath("data", "me", "username").String()
if err == nil {
s.PreferredUsername = username
s.User = username
Expand Down

0 comments on commit cd5fbef

Please sign in to comment.