Skip to content

Commit

Permalink
Merge pull request #314 from mrkschan/github-bearer-authz
Browse files Browse the repository at this point in the history
github: Use Authorization header for authentication
  • Loading branch information
bentranter authored Feb 24, 2020
2 parents 06e1f81 + cbc28e4 commit 58ff599
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions providers/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"io"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"

Expand Down Expand Up @@ -105,7 +104,9 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
return user, fmt.Errorf("%s cannot get user information without accessToken", p.providerName)
}

response, err := p.Client().Get(p.profileURL + "?access_token=" + url.QueryEscape(sess.AccessToken))
req, err := http.NewRequest("GET", p.profileURL, nil)
req.Header.Add("Authorization", "Bearer "+sess.AccessToken)
response, err := p.Client().Do(req)
if err != nil {
return user, err
}
Expand Down Expand Up @@ -172,7 +173,9 @@ func userFromReader(reader io.Reader, user *goth.User) error {
}

func getPrivateMail(p *Provider, sess *Session) (email string, err error) {
response, err := p.Client().Get(p.emailURL + "?access_token=" + url.QueryEscape(sess.AccessToken))
req, err := http.NewRequest("GET", p.emailURL, nil)
req.Header.Add("Authorization", "Bearer "+sess.AccessToken)
response, err := p.Client().Do(req)
if err != nil {
if response != nil {
response.Body.Close()
Expand Down

0 comments on commit 58ff599

Please sign in to comment.