def __init__(self, store_credentials_callback): self._refresh_token = None self._access_token = None self._account_id = None self._auth_lost_callback = None self._store_credentials = store_credentials_callback self._cookie_jar = CookieJar() self._session = create_client_session(cookie_jar=self._cookie_jar) self._session.headers = {} self._session.headers["User-Agent"] = self.LAUNCHER_USER_AGENT self._refreshing_task = None
def create_session(self, stored_credentials): self._current_session = create_client_session(cookie_jar=CookieJar()) self._current_session.max_redirects = 300 if stored_credentials is not None: morsel_list = pickle.loads(bytes.fromhex(stored_credentials['cookie_jar'])) for morsel in morsel_list: cookie_object = SimpleCookie() cookie_object[morsel.key] = morsel.value cookie_object[morsel.key]['domain'] = morsel['domain'] cookie_object[morsel.key]['path'] = morsel['path'] self._current_session.cookie_jar.update_cookies(cookie_object)
async def get_ws_url(): global ws_url async with create_client_session() as session: log.debug("DISCORD_WS_CHECK: Retrieving the WebSocket debugger URL...") headers = {"User-Agent": USER_AGENT} resp = await session.get( f"http://localhost:{DEBUGGING_PORT}/json/list?t=" f"{str(int(datetime.datetime.now().timestamp()))}", headers=headers) resp_json = await resp.json() ws_url = resp_json[0]["webSocketDebuggerUrl"] log.debug(f"DISCORD_WS_FOUND: Got WebSocket debugger URL {ws_url}!")
def __init__(self, reader, writer, token): super().__init__( Platform.ItchIo, # Choose platform from available list "0.1", # Version reader, writer, token) self._session = create_client_session() self.authenticated = False self.itch_db = None self.itch_db_cursor = None self.checking_for_new_games = False self.game_ids = []
def __init__(self, plugin): self._plugin = plugin self._auth_lost_callback = None self.token = None self.session_id = None self.refresh_token = None self.refresh_time = None self.user_id = None self.user_name = None self.__refresh_in_progress = False connector = create_tcp_connector(limit=30) self._session = create_client_session(connector=connector, timeout=aiohttp.ClientTimeout(total=120), cookie_jar=None) self._session.headers = { 'Authorization': None, 'Ubi-AppId': CLUB_APPID, "User-Agent": CHROME_USERAGENT, 'Ubi-SessionId': None }
async def retrieve_exchange_code(self): xsrf_token = None old_cookies_values = [ cookie.value for cookie in self._session.cookie_jar ] await self.request('GET', "https://www.epicgames.com/id/api/authenticate") await self.request('GET', "https://www.epicgames.com/id/api/csrf") cookies = [cookie for cookie in self._session.cookie_jar] cookies_to_set = dict() for new_cookie in cookies: if new_cookie.key in cookies_to_set and new_cookie.value in old_cookies_values: continue cookies_to_set[new_cookie.key] = new_cookie.value if new_cookie.key == 'XSRF-TOKEN': xsrf_token = new_cookie.value self._cookie_jar = CookieJar() self._session = create_client_session(cookie_jar=self._cookie_jar) self.update_cookies(cookies_to_set) headers = { "X-Epic-Event-Action": "login", "X-Epic-Event-Category": "login", "X-Epic-Strategy-Flags": "guardianKwsFlowEnabled=false;minorPreRegisterEnabled=false;registerEmailPreVerifyEnabled=false;guardianEmailVerifyEnabled=true;guardianEmbeddedDocusignEnabled=true", "X-Requested-With": "XMLHttpRequest", "X-XSRF-TOKEN": xsrf_token, "Referer": "https://www.epicgames.com/id/login/welcome" } response = await self.request( 'POST', "https://www.epicgames.com/id/api/exchange/generate", headers=headers) response = await response.json() return response['code']
def __init__(self): self._session = create_client_session(headers=self._DEFAULT_HEADERS)
def __init__(self): self._session = create_client_session()
def __init__(self): self._simpleauth_sess = None self._session = create_client_session(headers=self._DEFAULT_HEADERS)
async def _refresh_credentials_social_club(self): # There are instances where the bearer token provided by the get-user.json endpoint is insufficient (i.e., # sending a message to a user or getting the tags from the Google Tag Manager). This requires a separate access # (bearer) token from the https://socialclub.rockstargames.com/ website. # To refresh the Social Club bearer token (hereafter referred to as the BearerToken), first make a GET request # to https://signin.rockstargames.com/connect/check/socialclub?returnUrl=%2FBlocker%2FAuthCheck&lang=en-US. Make # sure to supply the current cookies as a header. Also, this request sets a new TS01a305c4 cookie, so its value # should be updated. # Next, make a POST request to https://signin.rockstargames.com/api/connect/check/socialclub. For request # headers, Content-Type must be application/json, Cookie must be the current cookies, and X-Requested-With must # be XMLHttpRequest. This response returns a JSON containing a single key: redirectUrl, which corresponds to the # unique URL for the user to refresh their bearer token. # Lastly, make a GET request to the specified redirectUrl and set the request header X-Requested-With to # XMLHttpRequest. This request sets the updated value for the BearerToken cookie, allowing further requests to # the Social Club API to be made. try: old_auth = self._current_sc_token if LOG_SENSITIVE_DATA: log.debug(f"ROCKSTAR_SC_BEARER_OLD: {old_auth}") else: log.debug(f"ROCKSTAR_SC_BEARER_OLD: {old_auth[:5]}***{old_auth[-3:]}") url = ("https://signin.rockstargames.com/connect/check/socialclub?returnUrl=%2FBlocker%2FAuthCheck&lang=en-" "US") headers = { "Cookie": await self.get_cookies_for_headers(), "User-Agent": USER_AGENT } resp = await self._current_session.get(url, headers=headers) await self._update_cookies_from_response(resp) filtered_cookies = resp.cookies if "TS01a305c4" in filtered_cookies: if LOG_SENSITIVE_DATA: log.debug(f"ROCKSTAR_SC_TS01a305c4: {str(filtered_cookies['TS01a305c4'].value)}") else: log.debug("ROCKSTAR_SC_TS01a305c4: ***") else: raise BackendError url = "https://signin.rockstargames.com/api/connect/check/socialclub" rsso_name, rsso_value = self._get_rsso_cookie() headers = { "Content-Type": "application/json", # A 400 error is returned by lazily submitting all cookies, so we need to send only the cookies that # matter. "Cookie": f"RMT={self.get_refresh_token()};{rsso_name}={rsso_value}", "Referer": ("https://signin.rockstargames.com/connect/check/socialclub?returnUrl=%2FBlocker%2FAuthCheck" "&lang=en-US"), "User-Agent": USER_AGENT, "X-Requested-With": "XMLHttpRequest" } data = { "fingerprint": self._fingerprint, "returnUrl": "/Blocker/AuthCheck" } # Using a context manager here will prevent the extra cookies from being sent. async with create_client_session() as s: resp = await s.post(url, json=data, headers=headers) await self._update_cookies_from_response(resp) # We need to set the new refresh token here, if it is updated. try: self.set_refresh_token(resp.cookies['RMT'].value) except KeyError: if LOG_SENSITIVE_DATA: log.debug("ROCKSTAR_RMT_MISSING: The RMT cookie is missing, presumably because the user has not " "enabled two-factor authentication. Proceeding anyways...") self.set_refresh_token('') resp_json = await resp.json() url = resp_json["redirectUrl"] if LOG_SENSITIVE_DATA: log.debug(f"ROCKSTAR_SC_REDIRECT_URL: {url}") headers = { "Content-Type": "application/json", "Cookie": await self.get_cookies_for_headers(), "User-Agent": USER_AGENT, "X-Requested-With": "XMLHttpRequest" } resp = await self._current_session.get(url, headers=headers, allow_redirects=False) await self._update_cookies_from_response(resp) filtered_cookies = resp.cookies for key, morsel in filtered_cookies.items(): if key == "BearerToken": if LOG_SENSITIVE_DATA: log.debug(f"ROCKSTAR_SC_BEARER_NEW: {morsel.value}") else: log.debug(f"ROCKSTAR_SC_BEARER_NEW: {morsel.value[:5]}***{morsel.value[-3:]}") self._current_sc_token = morsel.value if old_auth != self._current_sc_token: log.debug("ROCKSTAR_SC_REFRESH_SUCCESS: The Social Club user has been successfully " "re-authenticated!") break except aiohttp.ClientConnectorError: log.error(f"ROCKSTAR_PLUGIN_OFFLINE: The user is not online.") self._refreshing = False raise NetworkError except Exception as e: log.exception(f"ROCKSTAR_SC_REFRESH_FAILURE: The attempt to re-authenticate the user on the Social Club has" f" failed with the exception {repr(e)}. Logging the user out...") self._refreshing = False raise InvalidCredentials
def __init__(self): self._session = create_client_session(timeout=aiohttp.ClientTimeout( total=DEFAULT_TIMEOUT))
def __init__(self, store_credentials): self.cookieJar = CookieJar() self.cookieJar.set_cookies_updated_callback(store_credentials) self.session = create_client_session(cookie_jar=self.cookieJar)