I'm fairly new to coding but I'm trying to work on a bot that pulls some data from the blizzard api. The bot I have works fine but I'm having to go in and manually change the url for the json data every time the access token changes. I understand the token changes every 24 hours but i can't imagine developers have to constantly go to the console and pull up the new url with updated access token every day. I've been looking around through the blizzard OAuth documentation and I found the following code someone had posted for python:
import requests
import json
from requests.auth import HTTPBasicAuth
def create_access_token(client_id, client_secret, region = 'us'):
url = "https://%s.battle.net/oauth/token" % region
body = {"grant_type": 'client_credentials'}
auth = HTTPBasicAuth(client_id, client_secret)
response = requests.post(url, data=body, auth=auth)
return response.json()
create_access_token()
but when i pass my client id and my client secret to this, I don't get any information. Any help would be awesome. Thanks.