mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
Generate separate error when deauthorization is required
This commit is contained in:
parent
19ccfaf481
commit
11000b086d
@ -126,14 +126,16 @@ Troubleshooting
|
|||||||
The authentication didn't complete correctly for some reason. This can be caused by:
|
The authentication didn't complete correctly for some reason. This can be caused by:
|
||||||
|
|
||||||
- Using Internet Explorer. IE is [known](https://blogs.msdn.microsoft.com/ieinternals/2011/07/13/understanding-protocols/) to be broken. Please (temporarily) set your default browser to Edge, Chrome or Firefox and retry.
|
- Using Internet Explorer. IE is [known](https://blogs.msdn.microsoft.com/ieinternals/2011/07/13/understanding-protocols/) to be broken. Please (temporarily) set your default browser to Edge, Chrome or Firefox and retry.
|
||||||
|
- The Frontier authentication website is confused - see [Error: An error occured](#error-an-error-occured).
|
||||||
- Entering credentials for a different Cmdr - see [Error: Wrong Cmdr](#error-wrong-cmdr).
|
- Entering credentials for a different Cmdr - see [Error: Wrong Cmdr](#error-wrong-cmdr).
|
||||||
- Entering Steam credentials instead of Frontier credentials - see [Error: User not found](#error-user-not-found).
|
- Entering Steam credentials instead of Frontier credentials - see [Error: User not found](#error-user-not-found).
|
||||||
|
|
||||||
If none of the above helps, visit the [Frontier authentication website](https://auth.frontierstore.net/), log in and deauthorize "Elite Dangerous Market Connector". Then restart the app.
|
|
||||||
|
|
||||||
### Error: Invalid Credentials
|
### Error: Invalid Credentials
|
||||||
See [above](#app-repeatedly-opens-the-frontier-authentication-website).
|
See [above](#app-repeatedly-opens-the-frontier-authentication-website).
|
||||||
|
|
||||||
|
### Error: An error occured
|
||||||
|
The Frontier authentication website is confused. Visit the [Frontier authentication website](https://auth.frontierstore.net/), log in and deauthorize "Elite Dangerous Market Connector". Then restart the app.
|
||||||
|
|
||||||
### 500 internal server error
|
### 500 internal server error
|
||||||
Either:
|
Either:
|
||||||
|
|
||||||
|
26
companion.py
26
companion.py
@ -211,10 +211,13 @@ class Auth:
|
|||||||
raise CredentialsError('Error: %s' % data['error_description'][0])
|
raise CredentialsError('Error: %s' % data['error_description'][0])
|
||||||
elif data.get('error'):
|
elif data.get('error'):
|
||||||
raise CredentialsError('Error: %s' % data['error'][0])
|
raise CredentialsError('Error: %s' % data['error'][0])
|
||||||
|
elif data.get('message'):
|
||||||
|
raise CredentialsError('Error: %s' % data['message'][0])
|
||||||
else:
|
else:
|
||||||
raise CredentialsError()
|
raise CredentialsError()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
r = None
|
||||||
data = {
|
data = {
|
||||||
'grant_type': 'authorization_code',
|
'grant_type': 'authorization_code',
|
||||||
'client_id': CLIENT_ID,
|
'client_id': CLIENT_ID,
|
||||||
@ -223,9 +226,9 @@ class Auth:
|
|||||||
'redirect_uri': protocolhandler.redirect,
|
'redirect_uri': protocolhandler.redirect,
|
||||||
}
|
}
|
||||||
r = self.session.post(SERVER_AUTH + URL_TOKEN, data=data, timeout=timeout)
|
r = self.session.post(SERVER_AUTH + URL_TOKEN, data=data, timeout=timeout)
|
||||||
|
data = r.json()
|
||||||
if r.status_code == requests.codes.ok:
|
if r.status_code == requests.codes.ok:
|
||||||
print 'Auth\tNew token for %s' % self.cmdr.encode('utf-8')
|
print 'Auth\tNew token for %s' % self.cmdr.encode('utf-8')
|
||||||
data = r.json()
|
|
||||||
cmdrs = config.get('cmdrs')
|
cmdrs = config.get('cmdrs')
|
||||||
idx = cmdrs.index(self.cmdr)
|
idx = cmdrs.index(self.cmdr)
|
||||||
tokens = config.get('fdev_apikeys') or []
|
tokens = config.get('fdev_apikeys') or []
|
||||||
@ -234,13 +237,21 @@ class Auth:
|
|||||||
config.set('fdev_apikeys', tokens)
|
config.set('fdev_apikeys', tokens)
|
||||||
config.save() # Save settings now for use by command-line app
|
config.save() # Save settings now for use by command-line app
|
||||||
return data.get('access_token')
|
return data.get('access_token')
|
||||||
else:
|
|
||||||
print 'Auth\tCan\'t get token for %s' % self.cmdr.encode('utf-8')
|
|
||||||
self.dump(r)
|
|
||||||
except:
|
except:
|
||||||
print 'Auth\tCan\'t get token for %s' % self.cmdr.encode('utf-8')
|
print 'Auth\tCan\'t get token for %s' % self.cmdr.encode('utf-8')
|
||||||
print_exc()
|
print_exc()
|
||||||
|
if r: self.dump(r)
|
||||||
|
raise CredentialsError()
|
||||||
|
|
||||||
|
print 'Auth\tCan\'t get token for %s' % self.cmdr.encode('utf-8')
|
||||||
|
self.dump(r)
|
||||||
|
if data.get('error_description'):
|
||||||
|
raise CredentialsError('Error: %s' % data['error_description'])
|
||||||
|
elif data.get('error'):
|
||||||
|
raise CredentialsError('Error: %s' % data['error'])
|
||||||
|
elif data.get('message'):
|
||||||
|
raise CredentialsError('Error: %s' % data['message'])
|
||||||
|
else:
|
||||||
raise CredentialsError()
|
raise CredentialsError()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -255,8 +266,7 @@ class Auth:
|
|||||||
config.save() # Save settings now for use by command-line app
|
config.save() # Save settings now for use by command-line app
|
||||||
|
|
||||||
def dump(self, r):
|
def dump(self, r):
|
||||||
print_exc()
|
print 'Auth\t' + r.url, r.status_code, r.reason and r.reason.decode('utf-8') or 'None', r.text.encode('utf-8')
|
||||||
print 'Auth\t' + r.url, r.status_code, r.reason and r.reason.decode('utf-8') or 'None', r.headers
|
|
||||||
|
|
||||||
def base64URLEncode(self, text):
|
def base64URLEncode(self, text):
|
||||||
return base64.urlsafe_b64encode(text).replace('=', '')
|
return base64.urlsafe_b64encode(text).replace('=', '')
|
||||||
@ -360,6 +370,7 @@ class Session:
|
|||||||
r.raise_for_status() # Typically 403 "Forbidden" on token expiry
|
r.raise_for_status() # Typically 403 "Forbidden" on token expiry
|
||||||
data = r.json() # May also fail here if token expired since response is empty
|
data = r.json() # May also fail here if token expired since response is empty
|
||||||
except:
|
except:
|
||||||
|
print_exc()
|
||||||
self.dump(r)
|
self.dump(r)
|
||||||
self.close()
|
self.close()
|
||||||
if self.retrying: # Refresh just succeeded but this query failed! Force full re-authentication
|
if self.retrying: # Refresh just succeeded but this query failed! Force full re-authentication
|
||||||
@ -417,8 +428,7 @@ class Session:
|
|||||||
Auth.invalidate(self.credentials['cmdr'])
|
Auth.invalidate(self.credentials['cmdr'])
|
||||||
|
|
||||||
def dump(self, r):
|
def dump(self, r):
|
||||||
print_exc()
|
print 'cAPI\t' + r.url, r.status_code, r.reason and r.reason.encode('utf-8') or 'None', r.text.encode('utf-8')
|
||||||
print 'cAPI\t' + r.url, r.status_code, r.reason and r.reason.encode('utf-8') or 'None', r.headers
|
|
||||||
|
|
||||||
|
|
||||||
# Returns a shallow copy of the received data suitable for export to older tools - English commodity names and anomalies fixed up
|
# Returns a shallow copy of the received data suitable for export to older tools - English commodity names and anomalies fixed up
|
||||||
|
Loading…
x
Reference in New Issue
Block a user