Start breaking out esipy, first up: getting for login
This commit is contained in:
@@ -31,15 +31,24 @@ cache_path = os.path.join(config.savePath, config.ESI_CACHE)
|
||||
|
||||
from esipy.events import AFTER_TOKEN_REFRESH
|
||||
|
||||
from urllib.parse import urlencode
|
||||
|
||||
if not os.path.exists(cache_path):
|
||||
os.mkdir(cache_path)
|
||||
|
||||
file_cache = FileCache(cache_path)
|
||||
|
||||
|
||||
sso_url = "https://www.pyfa.io" # "https://login.eveonline.com" for actual login
|
||||
esi_url = "https://esi.tech.ccp.is"
|
||||
|
||||
oauth_authorize = '%s/oauth/authorize' % sso_url
|
||||
oauth_token = '%s/oauth/token' % sso_url
|
||||
|
||||
class EsiException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Servers(Enum):
|
||||
TQ = 0
|
||||
SISI = 1
|
||||
@@ -201,6 +210,8 @@ class Esi(object):
|
||||
char.accessTokenExpires = datetime.datetime.fromtimestamp(time.time() + tokenResponse['expires_in'])
|
||||
if 'refresh_token' in tokenResponse:
|
||||
char.refreshToken = config.cipher.encrypt(tokenResponse['refresh_token'].encode())
|
||||
|
||||
# remove, no longer need?
|
||||
if char.esi_client is not None:
|
||||
char.esi_client.security.update_token(tokenResponse)
|
||||
|
||||
@@ -219,7 +230,6 @@ class Esi(object):
|
||||
|
||||
def getLoginURI(self, redirect=None):
|
||||
self.state = str(uuid.uuid4())
|
||||
esisecurity = EsiSecurityProxy(sso_url=config.ESI_AUTH_PROXY)
|
||||
|
||||
args = {
|
||||
'state': self.state,
|
||||
@@ -231,7 +241,10 @@ class Esi(object):
|
||||
if redirect is not None:
|
||||
args['redirect'] = redirect
|
||||
|
||||
return esisecurity.get_auth_uri(**args)
|
||||
return '%s?%s' % (
|
||||
oauth_authorize,
|
||||
urlencode(args)
|
||||
)
|
||||
|
||||
def startServer(self): # todo: break this out into two functions: starting the server, and getting the URI
|
||||
pyfalog.debug("Starting server")
|
||||
|
||||
@@ -116,19 +116,6 @@ class EsiSecurityProxy(object):
|
||||
|
||||
return request_params
|
||||
|
||||
def get_auth_uri(self, *args, **kwargs):
|
||||
""" Constructs the full auth uri and returns it.
|
||||
|
||||
:param state: The state to pass through the auth process
|
||||
:param redirect: The URI that the proxy server will redirect to
|
||||
:return: the authorizationUrl with the correct parameters.
|
||||
"""
|
||||
|
||||
return '%s?%s' % (
|
||||
self.oauth_authorize,
|
||||
urlencode(kwargs)
|
||||
)
|
||||
|
||||
def get_refresh_token_params(self):
|
||||
""" Return the param object for the post() call to get the access_token
|
||||
from the refresh_token
|
||||
|
||||
Reference in New Issue
Block a user