Skip to content

Bug in the _get_client_credentials function when getting other-region data. #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Arcitec opened this issue Jul 5, 2021 · 0 comments

Comments

@Arcitec
Copy link

Arcitec commented Jul 5, 2021

Hi, I've noticed a small bug.

api.py: _get_client_credentials(self, region):

    def _get_client_credentials(self, region):
        path = '/oauth/token'
        data = {'grant_type': 'client_credentials'}
        auth = HTTPBasicAuth(self._client_id, self._client_secret)

        #url = 'https://{0}.battle.net{1}'.format(region, path)
        url = 'https://eu.battle.net{1}'.format(region, path)

As you can see, I intentionally commented out the "region.battle.net" code and replaced it with "eu.battle.net". Why?

Because:

# Code:
data = api.get_spell("tw", namespace="static-tw", id=195072, locale='zh_TW')
# Result:
# 2021-07-05 15:24:50,980 - wowapi - WARNING - Invalid response - 401 for https://tw.battle.net/oauth/token

Code 401 means "Unauthorized". I am not authorized to login to tw.battle.net.

Changing it to login to your own account's region and THEN querying the other regions is the correct way to use the API. And yes, to query data from another region you do need to provide a region to the wowapi.get_spell() etc APIs.

So the oauth login must be your region. The query must be the target region.

Furthermore, their documentation pages say that the data is segmented into region locks. Non-Chinese accounts can query all regions except China. Chinese accounts can only query Chinese regions (zh_CN):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant