Skip to content

GoG Galaxy Syncing savegames via the gog cloud

Paweł Lidwin edited this page Aug 29, 2024 · 12 revisions

Cloudsync for Savegames:

Obtaining Access Token

We have to get a bearer token authorized to do stuff related to specific game. We can do so by making a request below.

You can obtain CLIENT_ID and CLIENT_SECRET from game manifest, documented here

GET https://auth.gog.com/token?client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&grant_type=refresh_token&refresh_token={REFRESH_TOKEN}&without_new_session=1

For endpoints in cloudstorage.gog.com you have to use bearer token obtained this way, there is no need to store it anywhere.

Remote config endpoint

To see if a certain game supports this feature we ask for the clientId. Which can be acquired from goggame-<GAMEID>.info file in game directory.

GET https://remote-config.gog.com/components/galaxy_client/clients/<CLIENTID>?component_version=2.0.43

for DeusEx: Mankind Divided

which gives us back

{
    "version": "1.2.37",
    "content": {
        "MacOS": {
            "overlay": {
                "supported": false
            },
            "cloudStorage": {
                "enabled": false,
                "locations": []
            }
        },
        "Windows": {
            "overlay": {
                "supported": true
            },
            "cloudStorage": {
                "enabled": true,
                "locations": [
                    {
                        "name": "saves",
                        "location": "\u003C?DOCUMENTS?\u003E\/My Games\/Deus Ex Mankind Divided\/Saves"
                    }
                ]
            }
        },
        "cloudStorage": {
            "quota": 1048576000
        }
    },
    "bases": []
} 

Uploading files

Galaxy recursively uploads all the files inside of saves directory path you obtained earlier

In example below Quick Save (Backup)(12_28_2021 5-34-49 PM).jpg is a filename. If a file is in a directory filename would look like DIRECTORY NAME/Quick Save (Backup)(12_28_2021 5-34-49 PM).jpg

All files uploaded have to be gzip encoded with compression level of 6

Crucial headers in upload requests are

  • X-Object-Meta-LocalLastModified - Last modification date in UTC timezone in ISO 8601 format
  • Etag - a MD5 checksum of a file you are uploading
  • Authorization
HTTP/1.1 100 Continue

PUT /v1/>USERID>/>CLIENTID>/saves/Quick Save (Backup)(12_28_2021 5-34-49 PM).jpg?_gog_request_id=<REQUESTID> HTTP/1.1
Host: cloudstorage.gog.com
Accept: */*
Accept-Encoding: gzip
X-Session: 7058611697133901917
X-Send-Time: Sat, 29 Jan 2022 12:58:28 GMT
X-Schedule-Time: Sat, 29 Jan 2022 12:58:28 GMT
X-Operation: 61f539f41055dafc
X-Object-Meta-User-Agent: GOGGalaxyCommunicationService/2.0.4.164 (Windows_32bit)
X-Object-Meta-LocalLastModified: 2021-12-28T16:34:50+00:00
User-Agent: GOGGalaxyCommunicationService/2.0.4.164 (Windows_32bit)
Etag: f82b6bc83773cd1587460941b63c03b3
Content-Type: application/octet-stream
Content-Encoding: gzip
Authorization: Bearer TOKEN
Content-Length: 32250
Expect: 100-continue

Game used for this example is Disco Elysium.

Downloading files

Same as Uploading, except you use GET method, here you won't need any headers except Authorization.

You also should look for X-Object-Meta-LocalLastModified in response headers. And update downloaded files timestamp respectively.

Listing Files in the Cloud

To get the list of the files just point to the saves path in your request

GET /v1/<USERID>/<CLIENTID>

You may want to use Accept: application/json header, this will return more than names of the files.

TO DO: Add examples