I’m working on developing a personal “app” that just summarizes my own WoW profile data (characters, levels, reps, etc).
When I use the workflow here in my Python app, I get a response code 403. Code below:
oauth_url = "https://us.battle.net/oauth/token"
data = {'grant_type': 'client_credentials'}
oauth_response = requests.post(oauth_url, data=data, auth=(client_ID, client_secret))
token = oauth_response.json()['access_token']
profile_url="https://us.api.blizzard.com/profile/user/wow?namespace=profile-us&locale=en_US"
headers = {'Authorization': 'Bearer ' + token}
profile_response = requests.get(profile_url, headers=headers)
The response from the last get request is 403, despite getting a 200 from the OAuth post request.
If I generate the “request” in the browser using the profile API documentation page, I get a pre-formatted url that has an access token already included, in the format
https://us.api.blizzard.com/profile/user/wow?namespace=profile-us&locale=en_US&access_token=<access_token>
If I use this access token in my app, I can get a 200 response. But I don’t want to have to go to that webpage and generate a new one every time to run my script. What am I missing here? Apologies if this is obvious, I’m pretty new to OAuth in general.
edit: I should note that this is being prototyped in an IPython notebook run via Jupyter on my localhost.