Skip to content

Commit

Permalink
Merge pull request #256 from BlizzTrack/master
Browse files Browse the repository at this point in the history
Update battle.net provider to use the new oauth serivces
  • Loading branch information
bentranter authored Dec 10, 2018
2 parents 8d728df + 61ca297 commit 9e535b8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions providers/battlenet/battlenet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
"encoding/json"
"io/ioutil"
"net/http"
"net/url"

"fmt"

"github.com/markbates/goth"
"golang.org/x/oauth2"
)

const (
authURL string = "https://us.battle.net/oauth/authorize"
tokenURL string = "https://us.battle.net/oauth/token"
endpointUser string = "https://us.api.battle.net/account/user"
endpointUser string = "https://us.battle.net/oauth/userinfo"
)

// Provider is the implementation of `goth.Provider` for accessing Battle.net.
Expand Down Expand Up @@ -84,7 +84,15 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
}

// Get the userID, battlenet needs userID in order to get user profile info
response, err := p.Client().Get(endpointUser + "?access_token=" + url.QueryEscape(sess.AccessToken))
c := p.Client()
req, err := http.NewRequest("GET", endpointUser, nil)
if err != nil {
return user, err
}

req.Header.Add("Authorization", "Bearer "+sess.AccessToken)

response, err := c.Do(req)
if err != nil {
if response != nil {
response.Body.Close()
Expand Down

0 comments on commit 9e535b8

Please sign in to comment.