tylerbrawl / Galaxy-Plugin-Rockstar

MIT License
71 stars 7 forks source link

Forbidden 403 during get_played_games #139

Closed FriendsOfGalaxy closed 3 years ago

FriendsOfGalaxy commented 3 years ago

During I am logging into Rockstar plugin I get following exception in my logs:

2021-03-09 14:23:11,266 - asyncio - DEBUG - Using selector: KqueueSelector
2021-03-09 14:23:11,268 - galaxy.api.plugin - INFO - Using local address: 127.0.0.1:60656
2021-03-09 14:23:11,268 - galaxy.api.plugin - INFO - Creating plugin for platform rockstar, version 0.5.12
2021-03-09 14:23:11,343 - galaxy.api.jsonrpc - DEBUG - Received 66 bytes of data
2021-03-09 14:23:11,344 - galaxy.api.jsonrpc - INFO - Handling request: id=0, method=get_capabilities, params={}
2021-03-09 14:23:11,345 - root - DEBUG - Sending data: {"jsonrpc": "2.0", "id": "0", "result": {"platform_name": "rockstar", "features": ["ImportUserPresence", "ImportFriends", "ImportAchievements", "ImportOwnedGames", "ImportGameTime"], "token": "ee4ce16f-85b1-4700-b43f-ade712cb2290"}}
2021-03-09 14:23:11,551 - galaxy.api.jsonrpc - DEBUG - Received 24046 bytes of data
2021-03-09 14:23:11,552 - galaxy.api.jsonrpc - INFO - Handling request: id=1, method=initialize_cache, params={'data': '****'}
2021-03-09 14:23:11,552 - galaxy.task_manager - DEBUG - Task manager plugin internal: creating task 0 (tick)
2021-03-09 14:23:11,552 - root - DEBUG - Sending data: {"jsonrpc": "2.0", "id": "1", "result": null}
2021-03-09 14:23:11,653 - galaxy.api.jsonrpc - DEBUG - Received 54 bytes of data
2021-03-09 14:23:11,653 - galaxy.api.jsonrpc - INFO - Handling request: id=2, method=ping, params={}
2021-03-09 14:23:11,653 - root - DEBUG - Sending data: {"jsonrpc": "2.0", "id": "2", "result": null}
2021-03-09 14:23:12,026 - galaxy.api.jsonrpc - DEBUG - Received 23818 bytes of data
2021-03-09 14:23:12,027 - galaxy.api.jsonrpc - INFO - Handling request: id=3, method=init_authentication, params={'stored_credentials': '****'}
2021-03-09 14:23:12,027 - galaxy.task_manager - DEBUG - Task manager jsonrpc server: creating task 0 (init_authentication)
2021-03-09 14:23:12,028 - galaxy.task_manager - DEBUG - Task manager plugin external: creating task 0 (init_authentication)
2021-03-09 14:23:12,041 - root - INFO - INFO: The credentials were successfully obtained.
2021-03-09 14:23:12,041 - root - INFO - INFO: The stored credentials were successfully parsed. Beginning authentication...
2021-03-09 14:23:12,042 - root - DEBUG - ROCKSTAR_SC_BEARER_OLD: eyJhb***jpg
2021-03-09 14:23:13,100 - root - DEBUG - ROCKSTAR_SC_TS01a305c4: ***
2021-03-09 14:23:13,599 - root - DEBUG - ROCKSTAR_SC_BEARER_NEW: eyJhb***zUw
2021-03-09 14:23:13,599 - root - DEBUG - ROCKSTAR_SC_REFRESH_SUCCESS: The Social Club user has been successfully re-authenticated!
2021-03-09 14:23:13,599 - root - DEBUG - ROCKSTAR_HTTP_CHECK: Got bearer token: eyJhb***zUw
2021-03-09 14:23:14,120 - root - DEBUG - ROCKSTAR_HTTP_CHECK: Got display name: T*** / Got Rockstar ID: ***
2021-03-09 14:23:14,120 - root - DEBUG - ROCKSTAR_STORE_CREDENTIALS: Preparing to store credentials...
2021-03-09 14:23:14,121 - galaxy.api.jsonrpc - INFO - Sending notification: method=store_credentials, params={'display_name': '****', 'rockstar_id': '****', 'cookie_jar': '****', 'current_auth_token': '****', 'current_sc_token': '****', 'refresh_token': '****', 'fingerprint': '****'}
2021-03-09 14:23:14,121 - galaxy.api.jsonrpc - DEBUG - Sending 23803 bytes of data
2021-03-09 14:23:14,121 - galaxy.task_manager - DEBUG - Task manager plugin external: finished task 0 (init_authentication)
2021-03-09 14:23:14,121 - root - DEBUG - Sending data: {"jsonrpc": "2.0", "id": "3", "result": {"user_id": "140121911", "user_name": "aa"}}
2021-03-09 14:23:14,122 - galaxy.task_manager - DEBUG - Task manager jsonrpc server: finished task 0 (init_authentication)
2021-03-09 14:23:14,563 - root - DEBUG - Checking for new games...
2021-03-09 14:23:14,952 - root - WARNING - ROCKSTAR_SC_LIGHT_REFRESH_FAILED: The light method for refreshing the Social Club user's authentication has failed. Falling back to the strict refresh method...
2021-03-09 14:23:15,087 - root - DEBUG - ROCKSTAR_OLD_AUTH_REFRESH: ***

2021-03-09 14:23:14,563 - root - DEBUG - Checking for new games...
2021-03-09 14:23:14,952 - root - WARNING - ROCKSTAR_SC_LIGHT_REFRESH_FAILED: The light method for refreshing the Social Club user's authentication has failed. Falling back to the strict refresh method...
2021-03-09 14:23:15,087 - root - DEBUG - ROCKSTAR_OLD_AUTH_REFRESH: ***
2021-03-09 14:23:15,691 - root - DEBUG - ROCKSTAR_REFRESH_AUTH_COOKIE_FAILURE: The authentication cookie could not be found!
2021-03-09 14:23:15,691 - root - ERROR - ROCKSTAR_REFRESH_FAILURE: The attempt to re-authenticate the user has failed with the exception InvalidCredentials(). Logging the user out...
Traceback (most recent call last):
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 378, in get_played_games
    resp_json = await self._get_google_tag_data()
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 372, in _get_google_tag_data
    resp = await self._current_session.get(url, headers=headers)
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/aiohttp/client.py", line 625, in _request
    resp.raise_for_status()
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    headers=self.headers,
aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url=URL('https://socialclub.rockstargames.com/ajax/getGoogleTagManagerSetupData?_=1615296194695')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 711, in _refresh_credentials_social_club_light
    data=data, headers=headers, allow_redirects=True)
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/aiohttp/client.py", line 625, in _request
    resp.raise_for_status()
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    headers=self.headers,
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('https://socialclub.rockstargames.com/connect/refreshaccess')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 681, in _refresh_credentials_base
    raise InvalidCredentials
galaxy.api.errors.InvalidCredentials
2021-03-09 14:23:15,696 - root - ERROR - ROCKSTAR_PLAYED_GAMES_ERROR: The request to scrape the user's played games resulted in this exception: InvalidCredentials()
Traceback (most recent call last):
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 378, in get_played_games
    resp_json = await self._get_google_tag_data()
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 372, in _get_google_tag_data
    resp = await self._current_session.get(url, headers=headers)
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/aiohttp/client.py", line 625, in _request
    resp.raise_for_status()
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    headers=self.headers,
aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url=URL('https://socialclub.rockstargames.com/ajax/getGoogleTagManagerSetupData?_=1615296194695')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 711, in _refresh_credentials_social_club_light
    data=data, headers=headers, allow_redirects=True)
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/aiohttp/client.py", line 625, in _request
    resp.raise_for_status()
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    headers=self.headers,
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('https://socialclub.rockstargames.com/connect/refreshaccess')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 681, in _refresh_credentials_base
    raise InvalidCredentials
galaxy.api.errors.InvalidCredentials

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 396, in get_played_games
    await self._refresh_credentials_social_club_light()
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 736, in _refresh_credentials_social_club_light
    await self.refresh_credentials()
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 588, in refresh_credentials
    await self._refresh_credentials_base()
  File "/Users/aa/Library/Application Support/GOG.com/Galaxy/plugins/installed/rockstar_774732b5-69c4-405c-b6c9-92cd55740cfe/http_client.py", line 695, in _refresh_credentials_base
    raise InvalidCredentials
galaxy.api.errors.InvalidCredentials
2021-03-09 14:23:15,697 - root - ERROR - ROCKSTAR_PLAYED_GAMES_ERROR: The exception InvalidCredentials() was thrown when attempting to get the user's played games online. Falling back to log file check...

My credentials are correct, because I can login in to https://socialclub.rockstargames.com/. And the most thing is that after this invalid logging Galaxy see me as logged in user.

tylerbrawl commented 3 years ago

Sorry about that. For some reason, they renamed the "RequestVerificationToken" header to "__RequestVerificationToken." Your guess as to why they would do that is as good as mine.

Since the relevant changes were pushed to the master branch (34ef7ec41d3753d929f05abe9941ba0df86c51ab), I'll go ahead and close this issue. Thanks for letting me know.

FriendsOfGalaxy commented 3 years ago

@tylerbrawl Is it stable enough to release on for_release?

tylerbrawl commented 3 years ago

I cannot believe that I forgot to push the changes to the release branch. For an entire month, this problem was left unresolved, even though the fix was right there. I never cease to amaze myself.

To answer your question, though, the fix is stable enough. It has worked for the past month that I somehow left the changes unresolved on the release branch.

FriendsOfGalaxy commented 3 years ago

Ah, it happens :) It's merged!