Skip to content
Permalink
Browse files

Updated to work with latest version of esi

  • Loading branch information
zweizeichen committed Nov 28, 2019
1 parent 1125aa0 commit 7fe2f0a9655898812b9707e0f9bfd05ce1b10cd4
Showing with 14 additions and 3 deletions.
  1. +14 −3 util/tokenfetcher.py
@@ -1,8 +1,12 @@
# Works on Python 3.6+
#
# 1) Configure below
# 2) pip install esipy Flask
# 3) FLASK_APP=tokenfetcher.py flask run
# 4) Wait a couple of seconds for the browser to open

import random
import string
import webbrowser

from esipy import App
@@ -16,25 +20,32 @@
SCOPES = ['esi-universe.read_structures.v1', 'esi-markets.structure_markets.v1']

app = Flask(__name__)
esi_app = App.create(url="https://esi.tech.ccp.is/latest/swagger.json?datasource=tranquility")
esi_app = App.create(url="https://esi.evetech.net/latest/swagger.json?datasource=tranquility")

security = EsiSecurity(
app=esi_app,
redirect_uri='http://127.0.0.1:5000/ESICallback',
headers={'User-Agent': 'ESI Token Fetcher'},
client_id=CLIENT_ID,
secret_key=SECRET_KEY
)

client = EsiClient(
retry_requests=True,
header={'User-Agent': 'ESI Token Fetcher'},
headers={'User-Agent': 'ESI Token Fetcher'},
security=security
)

webbrowser.open_new(security.get_auth_uri(scopes=SCOPES))
state = ''.join(random.choices(string.ascii_letters + string.digits, k=32))
webbrowser.open_new(security.get_auth_uri(scopes=SCOPES, state=state))

@app.route('/ESICallback')
def esi_callback():
url_state = request.args.get('state', '')

if url_state != state:
return 'Invalid state token returned!'

code = request.args.get('code', '')

if code:

0 comments on commit 7fe2f0a

Please sign in to comment.
You can’t perform that action at this time.