mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 01:45:28 +00:00
[api] Add support for anonymous EOS sessions
These can be used to download the launcher and overlay/service updates without actually having to authenticate an account.
This commit is contained in:
parent
335619ff79
commit
3c831da310
|
@ -79,7 +79,8 @@ class EPCAPI:
|
||||||
self.user = session
|
self.user = session
|
||||||
return self.user
|
return self.user
|
||||||
|
|
||||||
def start_session(self, refresh_token: str = None, exchange_token: str = None) -> dict:
|
def start_session(self, refresh_token: str = None, exchange_token: str = None,
|
||||||
|
client_credentials: bool = False) -> dict:
|
||||||
if refresh_token:
|
if refresh_token:
|
||||||
params = dict(grant_type='refresh_token',
|
params = dict(grant_type='refresh_token',
|
||||||
refresh_token=refresh_token,
|
refresh_token=refresh_token,
|
||||||
|
@ -88,6 +89,9 @@ class EPCAPI:
|
||||||
params = dict(grant_type='exchange_code',
|
params = dict(grant_type='exchange_code',
|
||||||
exchange_code=exchange_token,
|
exchange_code=exchange_token,
|
||||||
token_type='eg1')
|
token_type='eg1')
|
||||||
|
elif client_credentials:
|
||||||
|
params = dict(grant_type='client_credentials',
|
||||||
|
token_type='eg1')
|
||||||
else:
|
else:
|
||||||
raise ValueError('At least one token type must be specified!')
|
raise ValueError('At least one token type must be specified!')
|
||||||
|
|
||||||
|
@ -102,9 +106,12 @@ class EPCAPI:
|
||||||
self.log.warning(f'Login to EGS API failed with errorCode: {j["errorCode"]}')
|
self.log.warning(f'Login to EGS API failed with errorCode: {j["errorCode"]}')
|
||||||
raise InvalidCredentialsError(j['errorCode'])
|
raise InvalidCredentialsError(j['errorCode'])
|
||||||
|
|
||||||
self.user = j
|
self.session.headers['Authorization'] = f'bearer {j["access_token"]}'
|
||||||
self.session.headers['Authorization'] = f'bearer {self.user["access_token"]}'
|
# only set user info when using non-anonymous login
|
||||||
return self.user
|
if not client_credentials:
|
||||||
|
self.user = j
|
||||||
|
|
||||||
|
return j
|
||||||
|
|
||||||
def invalidate_session(self): # unused
|
def invalidate_session(self): # unused
|
||||||
r = self.session.delete(f'https://{self._oauth_host}/account/api/oauth/sessions/kill/{self.access_token}')
|
r = self.session.delete(f'https://{self._oauth_host}/account/api/oauth/sessions/kill/{self.access_token}')
|
||||||
|
|
Loading…
Reference in a new issue