Skip to content

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

Open
@Arcitec

Description

@Arcitec

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):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions