API Reference

class bungied2auth.oauth.BungieOAuth(id_number, secret, context=False, redirect_url='/redirect', host=None, port=None, debug=None, load_dotenv=True)

Class that is used to get auth tokens from Bungie

api_data: dict
Bungie API data. This is set automatically on initialization. Contains two str keys: ‘id’ and ‘secret’. These are set correspondingly by id_number and secret.
redirect_url: str
Redirect url used to get Bungie’s auth response.
token: dict
Bungie authorization token. Contains two keys: ‘refresh’ and ‘expires’.
Parameters:
  • id_number – OAuth client_id from Bungie.
  • secret – OAuth client_secret from Bungie
  • host – the hostname to listen on. Set this to '0.0.0.0' to have the server available externally as well. Defaults to '127.0.0.1' or the host in the SERVER_NAME config variable if present.
  • port – the port of the webserver. Defaults to 5000 or the port defined in the SERVER_NAME config variable if present.
  • debug – if given, enable or disable debug mode. See debug.
  • load_dotenv – Load the nearest .env and .flaskenv files to set environment variables. Will also change the working directory to the directory containing the first file found.
  • contextssl_context from Flask.
get_oauth()

Spin up the flask server to OAuth authenticate.

Navigate to host:port. When you navigate to there, you must open the developer console and open to the network tab. Click the link, scroll to the bottom of Bungie’s page, and click the authorize button. When you do so, nothing will happen, but you’ll see a redirect network event that is cancelled (You don’t need to do anything when using https). You need to copy the link that was attempted to direct to, and go there directly. If all is well, the script will proceed to the next stage.

The resulting token will be written to self.token and file token.json