Skip to content

Commit

Permalink
fix(oauth): update oauth endpoints (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy012 authored Oct 22, 2023
1 parent 66ea41c commit 64fc552
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions blizzard.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ func (c *Client) SetRegionParameters(region Region, locale Locale) error {

switch region {
case CN:
c.oauthHost = "https://www.battlenet.com.cn"
c.oauthHost = "https://oauth.battlenet.com.cn"
c.apiHost = "https://gateway.battlenet.com.cn"
c.dynamicNamespace = "dynamic-zh"
c.dynamicClassicNamespace = "dynamic-classic-zh"
c.profileNamespace = "profile-zh"
c.staticNamespace = "static-zh"
c.staticClassicNamespace = "static-classic-zh"
default:
c.oauthHost = fmt.Sprintf("https://%s.battle.net", region)
c.oauthHost = "https://oauth.battle.net"
c.apiHost = fmt.Sprintf("https://%s.api.blizzard.com", region)
c.dynamicNamespace = fmt.Sprintf("dynamic-%s", region)
c.dynamicClassicNamespace = fmt.Sprintf("dynamic-classic-%s", region)
Expand All @@ -187,7 +187,7 @@ func (c *Client) SetRegionParameters(region Region, locale Locale) error {
c.staticClassicNamespace = fmt.Sprintf("static-classic-%s", region)
}

c.clntCredCfg.TokenURL = c.oauthHost + "/oauth/token"
c.clntCredCfg.TokenURL = c.oauthHost + "/token"
c.httpClient = c.clntCredCfg.Client(
context.WithValue(context.TODO(), oauth2.HTTPClient, c.cfg.HTTPClient),
)
Expand Down
10 changes: 5 additions & 5 deletions oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func (c *Client) AuthorizeConfig(redirectURI string, profiles ...oauth.Profile)
Scopes: scopes,
RedirectURL: redirectURI,
Endpoint: oauth2.Endpoint{
AuthURL: c.oauthHost + "/oauth/authorize",
TokenURL: c.oauthHost + "/oauth/token",
AuthURL: c.oauthHost + "/authorize",
TokenURL: c.oauthHost + "/token",
},
}

Expand All @@ -50,7 +50,7 @@ func (c *Client) AccessTokenRequest(ctx context.Context) error {
err error
)

req, err = http.NewRequestWithContext(ctx, "POST", c.oauthHost+"/oauth/token", strings.NewReader("grant_type=client_credentials"))
req, err = http.NewRequestWithContext(ctx, "POST", c.clntCredCfg.TokenURL, strings.NewReader("grant_type=client_credentials"))
if err != nil {
return err
}
Expand Down Expand Up @@ -92,7 +92,7 @@ func (c *Client) UserInfoHeader(token *oauth2.Token) (*oauth.UserInfo, []byte, e
err error
)

req, err = http.NewRequest("GET", c.oauthHost+"/oauth/userinfo", nil)
req, err = http.NewRequest("GET", c.oauthHost+"/userinfo", nil)
if err != nil {
return &dat, b, err
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (c *Client) TokenValidation(ctx context.Context, token *oauth2.Token) (*oau
err error
)

req, err = http.NewRequestWithContext(ctx, "GET", c.oauthHost+fmt.Sprintf("/oauth/check_token?token=%s", token.AccessToken), nil)
req, err = http.NewRequestWithContext(ctx, "GET", c.oauthHost+fmt.Sprintf("/v2/check_token?token=%s", token.AccessToken), nil)
if err != nil {
return &dat, b, err
}
Expand Down

0 comments on commit 64fc552

Please sign in to comment.