Very basic, reverse engineered, Google Photos mobile API client.
Made for uploading files as Pixel XL without relying on a physical device/emulator.
Install with git and pip:
pip install git+https://github.com/xob0t/gphotos_mobile_client --force-reinstall
OR download as zip and intall with pip:
pip install gphotos_mobile_client.zip
Note
If auth_data is omitted, GP_AUTH_DATA
env variable will be used
from gpmc import Client
path = "/path/to/media_file.jpg" # file or dir path
auth_data = "androidId=216e583113f43c75&app=com.google.android.apps.photos&client_sig=34bb24c05e47e0aefa65a58a762171d9b613a680..."
client = Client(auth_data=auth_data)
media_key = client.upload(target=path, progress=True)
print(media_key)
gp-upload "/path/to/media_file.jpg" --progress --auth_data "androidId=216e583113f43c75&app=com.google.android.apps.photos&client_sig=34bb24c05e47e0aefa65a58a762171d9b613a680..."
usage: gp-upload [-h] [--auth_data AUTH_DATA] [--progress] [--recursive] [--threads THREADS] [--force-upload] [--timeout TIMEOUT] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] path
Google Photos mobile client.
positional arguments:
path Path to the file or directory to upload.
options:
-h, --help show this help message and exit
--auth_data AUTH_DATA
Google auth data for authentication. If not provided, `GP_AUTH_DATA` env variable will be used.
--progress Display upload progress.
--recursive Scan the directory recursively.
--threads THREADS Number of threads to run uploads with. Defaults to 1.
--force-upload Upload files regardless of their presence in Google Photos (determined by hash).
--timeout TIMEOUT Requests timeout, seconds. Defaults to 30.
--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Set the logging level (default: INFO)
Below is a step by step instruction on how to accuire your Google account's mobile auth data in a simplest way possible.
You only need to do it once.
- Get a rooted android device or an emulator.
- Connect the device to your PC via ADB.
- Install https://httptoolkit.com
- In HTTP Toolkit, select Intercept - Android Device via ADB. Filter traffic with
contains(https://www.googleapis.com/auth/photos.native)
- Open Google Photos app and login with your account.
- There should be a single request found.
Copy request body as text.
- Now you've got yourself your auth_data! 🎉
-
403 Response Status
Try Google Photos ReVanced. Patch it yourself or use a patched apk https://github.com/j-hc/revanced-magisk-module/releases
It uses an alternative to google services, and the format of the auth request is a bit different. -
I logged into the app but didn’t see any authentication requests.
The app periodically refreshes its token. If it already has one, you’ll need to wait for it to request a new one. To avoid waiting, re-logging into your Google account should trigger the request.
- Disguse any file as media for GP to accept and store it: https://github.com/xob0t/gp-file-hide
- Manage library with bulk operations: https://github.com/xob0t/Google-Photos-Toolkit