Simulators
Google Drive simulator
google-drive-twin is a local, stateful simulator of the Google Drive API v3 for testing code that reads and writes Drive. It serves files and folders, uploads, downloads and exports, search with files.list, revisions, permissions, comments and replies, the change feed, shared drives and batch requests. Where it behaves differently from Drive, a line marked Differs from Google Drive says so beside the behavior, and “(unconfirmed)” marks behavior not yet checked against Drive.
The simulator never calls Google, and no share or comment sends an email or push notification.
Quickstart
Install the CLI, sign in and boot the simulator with RYSTIC_URL pointing at it.
On Pro you sign in with an API key from your account .
curl -fsSL https://www.rystic.ai/install.sh | sh
rystic login rys_… # your API key
export RYSTIC_URL=$(rystic run google-drive-twin -d --port 0 --scenario google-drive_media_vault --json | jq -r .data.url)
curl -s "$RYSTIC_URL/_rystic/version"
# -> {..."product":"google-drive-twin"...}
On Enterprise, the licensed edition signs in with a license file in place of the key: rystic login ./rystic-license.json (licensing ).
First calls
Read the scenario’s files, upload a small file and download it back:
AUTH='Authorization: Bearer ya29.placeholder'
curl -s -H "$AUTH" "$RYSTIC_URL/drive/v3/files?q=trashed%3Dfalse&fields=files(name)" | jq -c '[.files[].name]'
# -> ["2025 Shoots","Media Vault","reel-final.mp4","proofs-2025.tar.gz","IMG_0042.CR2","beach-sunrise.jpg"]
curl -s -H "$AUTH" -H 'Content-Type: text/plain' --data-binary 'hello' "$RYSTIC_URL/upload/drive/v3/files?uploadType=media&fields=id,name,size" | jq -c .
# -> {"id":"1rysticFile0000000000000000000001","name":"Untitled","size":"5"}
curl -s -H "$AUTH" "$RYSTIC_URL/drive/v3/files/1rysticFile0000000000000000000001?alt=media"
# -> hello
Connect your client
Point a Google client library at the simulator with any ya29. token. Both official libraries build every URL on https://www.googleapis.com. Their base-URL option alone does not move their upload URLs, so an upload you leave unpointed goes to the real Google Drive.
To leave your client unchanged, run the simulator behind the intercept gateway: boot with rystic run google-drive-twin -d --port 0 --intercept --scenario google-drive_media_vault, then run your code with rystic exec -- <command>. Calls to www.googleapis.com, uploads included, then reach the simulator. Python’s google-api-python-client reads its CA bundle only from HTTPLIB2_CA_CERTS, not from the variables rystic exec sets, so name the same bundle there: rystic exec -- sh -c 'HTTPLIB2_CA_CERTS="$SSL_CERT_FILE" python3 app.py'. To point the client instead, use the forms below.
Node (@googleapis/drive or googleapis) skips upload URLs when you set rootUrl, so hand the client a fetch that rewrites Google’s origin to the simulator’s and refuses anything else:
import { auth, drive as makeDrive } from "@googleapis/drive";
const twin = process.env.RYSTIC_URL;
const user = new auth.OAuth2();
user.setCredentials({ access_token: "ya29.placeholder" });
const drive = makeDrive({
version: "v3",
auth: user,
fetchImplementation: (url, init) => {
const raw = String(url instanceof Request ? url.url : url);
const target = raw.replace(/^https:\/\/www\.googleapis\.com/, twin);
if (!target.startsWith(twin + "/")) throw new Error(`refusing ${target}`);
return fetch(target, init);
},
});
const { data: f } = await drive.files.create({
requestBody: { name: "hello.txt" },
media: { mimeType: "text/plain", body: "hello" },
fields: "id,name",
});
Without the fetch, pass { rootUrl: process.env.RYSTIC_URL + "/" } as the second argument of every call that carries media, as well as to makeDrive.
Python (google-api-python-client) keeps uploads on https when you set api_endpoint, so build the client from the bundled Discovery document with its rootUrl rewritten. No request reaches Google, the document included:
import json
import os
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build_from_document
from googleapiclient.discovery_cache import get_static_doc
from googleapiclient.http import MediaInMemoryUpload
doc = json.loads(get_static_doc("drive", "v3"))
doc["rootUrl"] = os.environ["RYSTIC_URL"] + "/"
drive = build_from_document(doc, credentials=Credentials(token="ya29.placeholder"))
f = drive.files().create(
body={"name": "hello.txt"},
media_body=MediaInMemoryUpload(b"hello", mimetype="text/plain"),
fields="id,name",
).execute()
Another library must move its upload URLs as well as its metadata URLs. If the simulator’s log shows none of your writes, the override is not reaching the library. Pass --events=all to rystic run to log reads too.
No client has been checked against this simulator yet.
Token refresh
Google’s client libraries refresh the access token at Google’s OAuth token service before they call the API. Behind the intercept gateway, the simulator serves that service too, at oauth2.googleapis.com and accounts.google.com, so the refresh never leaves your machine:
POST https://oauth2.googleapis.com/token, or the olderhttps://accounts.google.com/o/oauth2/token, takes therefresh_tokenandauthorization_codegrants with any client ID and secret, sent in the form, as JSON or in Basic auth. It grants a refresh token or code the scenario binds as a credential, such as{"credentials": {"1//rystic-seeded-refresh-token": "member"}}in the boot seed. It returns an access token starting withya29., withexpires_in3599, that acts as the user the credential names (memberabove). Anauthorization_codegrant also returns a refresh token.- Any other refresh token or code returns 400
invalid_grant. Start the simulator withRYSTIC_TOKEN_GRANTS=anyto grant any value, asmember. GETorPOST https://oauth2.googleapis.com/tokeninfodescribes a token the simulator granted, read fromaccess_tokenor the bearer header, and returns 400invalid_tokenfor any other.GET https://accounts.google.com/.well-known/openid-configurationreturns a discovery document naming the token, authorization and userinfo endpoints and the signing keys.
With the Gmail simulator in the same stack, the gateway sends the token service to one of the two. Each accepts the access token either one granted, and acts it as the same user when both seeds bind its refresh token to that user.
Differs from Google Drive: the refresh grant returns the same access token each time and it never expires, and the revocation endpoint is not served.
Each example below names the token host in a Host header, as the gateway does for your client. Bind a refresh token to the scenario’s user member, as a scenario’s credentials do; "keep": true adds it and keeps every binding already there, a binding of this same token included. Refresh it with any client:
curl -s -X POST "$RYSTIC_URL/_rystic/credentials" -d '{"bindings": {"1//rystic-seeded-refresh-token": "member"}, "keep": true}'
curl -s "$RYSTIC_URL/token" -H 'Host: oauth2.googleapis.com' -d grant_type=refresh_token -d refresh_token=1//rystic-seeded-refresh-token -d client_id=placeholder.apps.googleusercontent.com -d client_secret=placeholder | jq -c '{token_type, expires_in, prefix: .access_token[:5]}'
# -> {"token_type":"Bearer","expires_in":3599,"prefix":"ya29."}
A refresh token the scenario does not bind returns 400 invalid_grant:
curl -s "$RYSTIC_URL/token" -H 'Host: oauth2.googleapis.com' -d grant_type=refresh_token -d refresh_token=1//not-seeded -d client_id=placeholder.apps.googleusercontent.com -o /dev/null -w '%{http_code}\n'
# -> 400
curl -s "$RYSTIC_URL/token" -H 'Host: oauth2.googleapis.com' -d grant_type=refresh_token -d refresh_token=1//not-seeded -d client_id=placeholder.apps.googleusercontent.com | jq -c '{error}'
# -> {"error":"invalid_grant"}
Call the API with the access token the refresh returns:
TOKEN=$(curl -s "$RYSTIC_URL/token" -H 'Host: oauth2.googleapis.com' -d grant_type=refresh_token -d refresh_token=1//rystic-seeded-refresh-token -d client_id=placeholder.apps.googleusercontent.com | jq -r .access_token)
curl -s "$RYSTIC_URL/drive/v3/about?fields=user" -H "Authorization: Bearer $TOKEN" | jq -c '.user | {permissionId, displayName}'
# -> {"permissionId":"member","displayName":"Juno Park"}
An authorization_code grant also returns a refresh token, and no ID token:
curl -s -X POST "$RYSTIC_URL/_rystic/credentials" -d '{"bindings": {"4/rystic-consent-code": "member"}, "keep": true}'
curl -s "$RYSTIC_URL/token" -H 'Host: oauth2.googleapis.com' -d grant_type=authorization_code -d code=4/rystic-consent-code -d client_id=placeholder.apps.googleusercontent.com -d redirect_uri=http://localhost:3000/callback | jq -c '{refresh: (.refresh_token | startswith("1//")), id_token}'
# -> {"refresh":true,"id_token":null}
The older path takes the same grants, here as JSON, and a client may send itself in Basic auth. Each refresh of one refresh token returns the same access token:
curl -s "$RYSTIC_URL/o/oauth2/token" -H 'Host: accounts.google.com' -H 'Content-Type: application/json' -d '{"grant_type": "refresh_token", "refresh_token": "1//rystic-seeded-refresh-token", "client_id": "placeholder.apps.googleusercontent.com"}' | jq -c --arg t "$TOKEN" '{same: (.access_token == $t)}'
# -> {"same":true}
curl -s "$RYSTIC_URL/token" -H 'Host: oauth2.googleapis.com' -u placeholder.apps.googleusercontent.com:placeholder -d grant_type=refresh_token -d refresh_token=1//rystic-seeded-refresh-token | jq -c --arg t "$TOKEN" '{same: (.access_token == $t)}'
# -> {"same":true}
tokeninfo describes a granted token and returns 400 invalid_token for any other:
curl -s "$RYSTIC_URL/tokeninfo?access_token=$TOKEN" -H 'Host: oauth2.googleapis.com' | jq -c '{sub, expires_in}'
# -> {"sub":"member","expires_in":"3599"}
curl -s "$RYSTIC_URL/tokeninfo?access_token=ya29.not-granted" -H 'Host: oauth2.googleapis.com' -o /dev/null -w '%{http_code}\n'
# -> 400
curl -s "$RYSTIC_URL/tokeninfo?access_token=ya29.not-granted" -H 'Host: oauth2.googleapis.com' | jq -c '{error}'
# -> {"error":"invalid_token"}
A refresh token bound to another of the scenario’s users acts as that user, here the collaborator Kit Alvarez:
curl -s -X POST "$RYSTIC_URL/_rystic/credentials" -d '{"bindings": {"1//kit-refresh-token": "10222233334444555567"}, "keep": true}'
KIT=$(curl -s "$RYSTIC_URL/token" -H 'Host: oauth2.googleapis.com' -d grant_type=refresh_token -d refresh_token=1//kit-refresh-token -d client_id=placeholder.apps.googleusercontent.com | jq -r .access_token)
curl -s "$RYSTIC_URL/drive/v3/about?fields=user" -H "Authorization: Bearer $KIT" | jq -c '.user | {permissionId, displayName}'
# -> {"permissionId":"10222233334444555567","displayName":"Kit Alvarez"}
Sign in with Google
An app’s “Sign in with Google” completes against the simulator behind the gateway, as one of the users the scenario gives a refresh token, such as member through {"credentials": {"1//rystic-seeded-refresh-token": "member"}} in the boot seed:
| Endpoint | What it does |
|---|---|
GET https://accounts.google.com/o/oauth2/v2/auth, or the older /o/oauth2/auth | Shows a consent page listing each such user by name and email. Choosing one redirects to the app’s redirect_uri with a code, the scope and the state. |
POST to the same URL | Signs in without a browser, as a test’s curl can, as the user the user form field names by email or scenario label, such as member. With one user to offer, user may be left out. |
POST https://oauth2.googleapis.com/token | Redeems the code once, with the authorization_code grant, for the client and redirect_uri the consent page was opened with. It returns the user’s refresh token and its access token. |
GET or POST https://openidconnect.googleapis.com/v1/userinfo | Describes the user an access token acts as, and returns 401 for any other token. |
GET https://accounts.google.com/oauth2/v3/certs | Publishes the key that signs ID tokens. |
When the scope includes openid, the code’s grant also returns an RS256 ID token. Its claims are:
iss:https://accounts.google.com.audandazp: the client ID.sub,email,email_verifiedandname: the user’s.nameandpictureare the user’s DrivedisplayNameandphotoLink.nonce: the one the consent page was opened with.
With the Gmail simulator in the same stack, the gateway sends sign-in to one of the two, and the access token a sign-in returns works on both.
Differs from Google Drive: the consent page asks for no password and offers only the users the scenario gives a refresh token, and a sign-in returns that user’s refresh token, the same each time. The signing keys are at accounts.google.com/oauth2/v3/certs, which the discovery document names as jwks_uri, not at www.googleapis.com/oauth2/v3/certs, so a library that fetches Google’s keys from that fixed address cannot verify an ID token. While the simulator runs behind the gateway, every other accounts.google.com page reaches it and returns 404.
The discovery document names each endpoint:
curl -s "$RYSTIC_URL/.well-known/openid-configuration" -H 'Host: accounts.google.com' | jq -c '{authorization_endpoint, userinfo_endpoint, jwks_uri}'
# -> {"authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth","userinfo_endpoint":"https://openidconnect.googleapis.com/v1/userinfo","jwks_uri":"https://accounts.google.com/oauth2/v3/certs"}
Sign in as the scenario’s user without a browser. The response redirects to the app’s redirect_uri with a code, the scope and the state:
AUTH="$RYSTIC_URL/o/oauth2/v2/auth?response_type=code&client_id=placeholder.apps.googleusercontent.com&redirect_uri=http://localhost:3000/callback&scope=openid%20email%20profile&state=st-1&nonce=n-1"
LOCATION=$(curl -s -X POST "$AUTH" -H 'Host: accounts.google.com' -d user=member -o /dev/null -w '%{redirect_url}')
echo "$LOCATION" | sed -E 's/code=[^&]+/code=.../'
# -> http://localhost:3000/callback?code=...&scope=openid+email+profile&state=st-1
Redeem the code for the user’s tokens and an ID token, whose claims name the user and echo the nonce. A second redemption returns 400 invalid_grant:
CODE=$(echo "$LOCATION" | sed -E 's/.*[?&]code=([^&]+).*/\1/')
ANSWER=$(curl -s "$RYSTIC_URL/token" -H 'Host: oauth2.googleapis.com' -d grant_type=authorization_code -d "code=$CODE" -d client_id=placeholder.apps.googleusercontent.com -d redirect_uri=http://localhost:3000/callback)
echo "$ANSWER" | jq -c '{refresh_token, token_type}'
# -> {"refresh_token":"1//rystic-seeded-refresh-token","token_type":"Bearer"}
echo "$ANSWER" | jq -c '.id_token | split(".")[1] | gsub("-"; "+") | gsub("_"; "/") | . + ("=" * ((4 - length % 4) % 4)) | @base64d | fromjson | {iss, aud, email, email_verified, nonce}'
# -> {"iss":"https://accounts.google.com","aud":"placeholder.apps.googleusercontent.com","email":"juno.park@studio.example","email_verified":true,"nonce":"n-1"}
curl -s "$RYSTIC_URL/token" -H 'Host: oauth2.googleapis.com' -d grant_type=authorization_code -d "code=$CODE" -d client_id=placeholder.apps.googleusercontent.com -d redirect_uri=http://localhost:3000/callback | jq -c '{error}'
# -> {"error":"invalid_grant"}
userinfo describes the user the access token acts as:
curl -s "$RYSTIC_URL/v1/userinfo" -H 'Host: openidconnect.googleapis.com' -H "Authorization: Bearer $(echo "$ANSWER" | jq -r .access_token)" | jq -c '{email, email_verified, name}'
# -> {"email":"juno.park@studio.example","email_verified":true,"name":"Juno Park"}
Auth
Send an OAuth 2 access token as Drive reads it, in Authorization: Bearer ya29.…. The simulator accepts any bearer value that starts with ya29., the prefix every Google access token carries.
Differs from Google Drive: the simulator never checks that Google issued a token, and an unbound token does not pick the user (below).
A bearer that does not start with ya29. is refused as Drive refuses an invalid token. It returns 401 authError “Request had invalid authentication credentials” at location Authorization, with WWW-Authenticate: Bearer realm="https://accounts.google.com/", error="invalid_token".
A request with no Authorization header, an empty bearer value or another scheme has no credential. The simulator refuses it as Drive does on that method, before the file lookup:
| Method | Response |
|---|---|
| most methods | 401 required “Login Required.” |
files.list, files.get and the comments and replies methods | 403 forbidden “Method doesn’t allow unregistered callers” |
files.export and files.get with alt=media | 403 forbidden “The request is missing a valid API key.” |
Every request acts as the scenario’s own user, permission id member, whatever the token says. To act as another of the scenario’s users, send X-Rystic-Actor: <permissionId> or bind a token to its permission id (Many clients, one simulator). GET /_rystic/inspect lists the users under state_user, and the media vault’s collaborator Kit Alvarez is 10222233334444555567.
Access by role
Access follows the caller’s role on the file. The owner’s role is owner. Anyone else holds the highest role that a permission on the file or on a folder above it grants, anyone links included. The simulator works out ownedByMe, capabilities, shared, permissions and permissionIds for each caller. On a My Drive file, a reader or commenter gets neither permissions nor permissionIds. On a file inside a shared folder, permissions.list and permissions.get show the folder’s grant with inherited: true in permissionDetails, before any grant the file itself gives the same user. Its role is the highest of those grants.
| Caller | What it gets |
|---|---|
| no role on the file | 404 notFound, and files.list leaves the file out |
no role on the folder a files.update moves the file into, or an id naming no file | 404 notFound naming that id, whatever role the caller holds on the file |
| a reader or commenter | 403 insufficientFilePermissions on an update, on permissions.list and on a share |
| a reader | 403 insufficientFilePermissions on a comment too |
| a reader, commenter or writer, on a My Drive file | 403 insufficientFilePermissions on a delete, and on a trash or restore (unconfirmed) |
| anyone but a comment’s or reply’s author | 200 with the record unchanged on an edit, and 403 on a delete |
In a shared drive, trash, move and share follow the member’s role instead (Shared drives). A permission created with sendNotificationEmail sends nothing: the user holds the role.
A My Drive file that permissions.create shares directly with the caller has sharedWithMeTime and sharingUser, the user who shared it. Commenting on a file marks it viewed and modified by the comment’s author: viewedByMe turns true, and viewedByMeTime and modifiedByMeTime take the comment’s time (Read the members that depend on the caller).
The simulator works out a writer’s and a commenter’s capabilities from the owner’s and the reader’s (unconfirmed).
API version
The simulator serves Drive API v3: /drive/v3 for metadata, /upload/drive/v3 for uploads and /batch/drive/v3 for batches. Its request and response fields follow Drive’s Discovery document at revision 20260916.
The version is in the path, so pinning it is calling /drive/v3. A request to another version, such as /drive/v2/files, returns the unserved-route 404 (Coverage).
Errors and limits
Error format
A refusal returns Google’s JSON error envelope, {"error": {…}}, whose members are these:
| Member | Meaning |
|---|---|
error.code | the HTTP status |
error.message | a readable message |
error.errors | one entry with domain, reason (such as notFound or invalidParameter) and message, plus location and locationType when a parameter is at fault |
error.status | on some refusals only, a status name such as INVALID_ARGUMENT |
error.details | only when a boolean parameter of files.delete does not parse (supportsAllDrives=maybe): a google.rpc.BadRequest whose fieldViolations name the field. Its errors entry then has reason invalid and no domain or location |
Two upload refusals are text/plain, outside the envelope:
| Request | Response |
|---|---|
an unknown uploadType | 400 Bad Request |
a resumable upload_id the simulator did not issue | 404 |
Rate limits
The simulator counts requests against the Drive API’s per-minute quotas but refuses none unless you turn the quotas on.
Differs from Google Drive: with no setting, nothing returns 429 rateLimitExceeded, however fast you call.
rate_limits: real turns the quotas on: in the stack file, as in google-drive: {product: google-drive-twin, port: 8095, rate_limits: real}, at boot with rystic run --rate-limits real or RYSTIC_RATE_LIMITS=real, or mid-run with curl -s -X POST "$RYSTIC_URL/_rystic/network" -d '{"rate_limits": "real"}'.
Google prices each method in quota units, with 325,000 units a minute per user and 1,000,000 per project. Each price group gets its share as a count per token and one for all tokens, in a one-minute window:
| Methods | Units | Per token | All tokens |
|---|---|---|---|
single reads, files.generateIds, changes.getStartPageToken, operations.get | 5 | 65,000 | 200,000 |
list methods | 100 | 3,250 | 10,000 |
| writes, with media and multipart uploads | 50 | 6,500 | 20,000 |
alt=media reads, files.export, files.download | 200 | 1,625 | 5,000 |
A request past a limit returns 429 rateLimitExceeded in domain usageLimits with no Retry-After (Rate limits).
Differs from Google Drive: Drive spends all units from one budget, so mixed traffic runs out later here.
Differs from Google Drive: Google’s docs say a quota overrun returns 403 userRateLimitExceeded. The simulator returns the 429 body Google documents (unconfirmed).
Differs from Google Drive: a count is per token, not per user, and a batch’s parts count toward none.
Pagination
Each list method takes these page sizes:
| Method | Default pageSize | Accepted pageSize |
|---|---|---|
files.list, changes.list | 100 | 1 to 1000 |
revisions.list | 200 | 1 to 1000 |
permissions.list | 100 | 1 to 100 |
comments.list, replies.list | 20 | 1 to 100 |
drives.list | 10 | 1 to 100 |
| Request | Response |
|---|---|
a pageSize outside its range | 400 invalidParameter at location page_size, never a smaller page |
a pageSize that is not a number, such as abc, on revisions.list | the default page (unconfirmed) |
a pageToken the listing did not issue | 400 invalid; the first page on comments.list and replies.list (unconfirmed) |
The change feed’s tokens work differently (Change feed).
/_rystic/page-cap caps pageSize; name the route with its /drive/v3 prefix, as in GET /drive/v3/files.
Idempotency
The simulator reads no idempotency key, so a retried files.create or upload makes a second file. To make creating a file safe to retry, give a metadata-only or multipart files.create an id from files.generateIds. A resend whose id a file already holds returns 409 fileIdInUse and writes nothing. files.copy ignores that id (Limitations). drives.create takes a requestId instead (Shared drives).
Coverage
The simulator covers the Drive v3 surface for one user’s My Drive and its shared drives. files.watch, changes.watch and channels.stop are out of scope because their notifications go to an address you register: poll changes.list instead. Labels, approvals, access proposals, apps, files.generateCseToken and the deprecated teamdrives methods are out of scope too.
Differs from Google Drive: a path Drive doesn’t have returns 404 notFound naming a file that does not exist, not Drive’s own error for that path.
56 routes, counted from the simulator’s route table.
Show all operations
| Resource | Operations |
|---|---|
| About (1) | GET /drive/v3/about |
| Comment (5) | GET, POST /drive/v3/files/{fileId}/comments; GET, PATCH, DELETE /drive/v3/files/{fileId}/comments/{commentId} |
| File (15) | GET /drive/v3/changes; GET, POST /drive/v3/files; DELETE /drive/v3/files/trash; GET, PATCH, DELETE /drive/v3/files/{fileId}; GET /drive/v3/files/{fileId}?alt=media; POST /drive/v3/files/{fileId}/copy; POST /drive/v3/files/{fileId}/download; GET /drive/v3/files/{fileId}/export; POST /upload/drive/v3/files; POST /upload/drive/v3/files?uploadType=multipart; PATCH /upload/drive/v3/files/{fileId}?uploadType=media; PATCH /upload/drive/v3/files/{fileId}?uploadType=multipart |
| Generated file ID (1) | GET /drive/v3/files/generateIds |
| Long-running operation (1) | GET /drive/v3/operations/{name} |
| Permission (5) | GET, POST /drive/v3/files/{fileId}/permissions; GET, PATCH, DELETE /drive/v3/files/{fileId}/permissions/{permissionId} |
| Reply (5) | GET, POST /drive/v3/files/{fileId}/comments/{commentId}/replies; GET, PATCH, DELETE /drive/v3/files/{fileId}/comments/{commentId}/replies/{replyId} |
| Revision (5) | GET /drive/v3/files/{fileId}/revisions; GET, PATCH, DELETE /drive/v3/files/{fileId}/revisions/{revisionId}; GET /drive/v3/files/{fileId}/revisions/{revisionId}?alt=media |
| Shared drive (9) | POST /batch/drive/v3; GET /drive/v3/changes/startPageToken; GET, POST /drive/v3/drives; GET, PATCH, DELETE /drive/v3/drives/{driveId}; POST /drive/v3/drives/{driveId}/hide; POST /drive/v3/drives/{driveId}/unhide |
Also served, outside the model: GET /upload/drive/v3/files?uploadType=resumable, POST /upload/drive/v3/files?uploadType=resumable, PUT /upload/drive/v3/files?uploadType=resumable, DELETE /upload/drive/v3/files?uploadType=resumable, GET /upload/drive/v3/files/{fileId}?uploadType=resumable, POST /upload/drive/v3/files/{fileId}?uploadType=resumable, PUT /upload/drive/v3/files/{fileId}?uploadType=resumable, PATCH /upload/drive/v3/files/{fileId}?uploadType=resumable, DELETE /upload/drive/v3/files/{fileId}?uploadType=resumable.
Feed effects. No write emits a feed effect; watch requests instead. Each call appears on the event feed (/_rystic/events) as a request event, and reading the record back shows what it changed.
Scenarios
The simulator ships 5 scenarios; the quickstart boots google-drive_media_vault.
| Scenario | What it is for | What it seeds | Clock |
|---|---|---|---|
google-drive_fresh_mydrive | An empty personal Drive | about 1, file 1, user 1 | 2026-02-02T00:00:00Z |
google-drive_media_vault (default) | A photographer’s binary archive | about 1, file 7, permission 6, revision 4, user 2 | 2026-02-02T00:00:00Z |
google-drive_shared_inbox | An account whose interesting files belong to other people | about 1, file 6, permission 3, revision 1, user 3 | 2026-02-02T00:00:00Z |
google-drive_team_workspace | A My Drive tree Dana Okafor owns, shared with Milo Reyes (writer) and Priya Shah (commenter) | about 1, file 8, permission 14, revision 1, user 3 | 2026-02-02T00:00:00Z |
google-drive_trash_backlog | A My Drive whose trash is full from boot | about 1, file 6, permission 3, revision 1, user 2 | 2026-02-02T00:00:00Z |
What each scenario holds:
google-drive_fresh_mydrive: One owner and an empty My Drive root, so every listing starts empty androotnames that folder.google-drive_media_vault:- Color-coded folders holding a JPEG, an MP4, a camera RAW and a tar.gz of proofs.
- Each file has real bytes, MD5 and SHA checksums and a head revision.
- Three have properties or app properties.
- One file is shared with anyone who has the link.
google-drive_shared_inbox: Three items shared in by a vendor and a partner, with ownedByMe false, plus a shortcut filed in the caller’s own folder pointing at one of them.google-drive_team_workspace:- A two-level folder tree, three Google-native editor files, a binary PDF and a content-restricted policy doc.
- Folder listings, mimeType queries and export links each have files to return.
- Each caller’s access follows its role on the file.
google-drive_trash_backlog:- One live doc beside a folder trashed outright, a doc trashed only with its parent and a trashed sheet and image.
- Trashed filters, untrash and empty trash each have files to act on.
Boot one by name, or load one into a running simulator:
rystic run google-drive-twin -d --port 0 --scenario google-drive_media_vault
curl -s -X POST "$RYSTIC_URL/_rystic/scenario" -d '{"name":"google-drive_media_vault"}'
What the scenarios do not hold
- Every user, address and file is synthetic: nothing comes from a real Google account, and every address is on an
.exampledomain. - A scenario’s seeded files are not in the change feed: take a start token, list them with
files.list, then poll from the token (Change feed). - Seeded binary files download real bytes that match their
sizeandmd5Checksum, but each is tens of kilobytes of synthetic content, not a real photo or video. - No scenario holds a shared drive: create one with
drives.create(Shared drives).
Seeding state
Each resource is one register, keyed as this table shows, and a key of several parts joins them with /.
| Register | Keyed by |
|---|---|
state_user | permission id |
state_file | file id |
state_revision | <fileId>/<revisionId>, its bytes in body_b64 or named by content_ref |
state_permission | <fileId>/<permissionId> |
state_comment | <fileId>/<commentId> |
state_reply | <fileId>/<commentId>/<replyId> |
state_drive | drive id; its members are state_permission records whose fileId is the drive’s id |
state_generated_id | id |
state_about | kind |
state_operation | name |
A file with bytes is a state_file whose headRevisionId names a state_revision holding them. Seed a text file and read its bytes back:
AUTH='Authorization: Bearer ya29.placeholder'
curl -s -X POST "$RYSTIC_URL/_rystic/seed" -d '{"state_file": {"notes1": {"id": "notes1", "name": "notes.txt", "mimeType": "text/plain", "parents": [], "owners": [{"permissionId": "member"}], "headRevisionId": "r1"}}, "state_revision": {"notes1/r1": {"fileId": "notes1", "id": "r1", "mimeType": "text/plain", "body_b64": "aGVsbG8gd29ybGQ="}}}'
curl -s -H "$AUTH" "$RYSTIC_URL/drive/v3/files/notes1?alt=media"
# -> hello world
A revision can name its bytes with "content_ref": "file:<path>" instead of body_b64. The path is slash-separated, under the folder that RYSTIC_CONTENT_ROOT names when the simulator starts. Set it when you start the simulator, as in rystic run google-drive-twin --runner native --env RYSTIC_CONTENT_ROOT=/data/drive: the Docker runner does not mount that folder.
The simulator reads that file and never writes to it. So a multi-gigabyte file costs only its metadata in memory: downloads stream from disk, a Range included, and files.copy points the copy at the same file. A seed whose content_ref names no such file is refused with 400. Give the file and the revision their size and md5Checksum, since the simulator returns them as seeded.
Seeding covers seed files, the seed route’s empty 204 and the 400s it returns for what it refuses.
Features
Each feature has its own page:
- Change feed: The change feed a sync client polls: a start token, then changes.list from the saved token, one entry per changed file as the caller can read it.
- Rate limits: Turn on the Drive API’s per-minute quotas, so a request past its price group’s share returns Drive’s 429 rateLimitExceeded error.
- Search and field selectors: files.list search terms and orderBy, and how fields narrows each route’s response.
- Shared drives: Shared drives and their members: create, rename, hide and delete a drive, with each caller’s access set by its membership role.
- Uploads and downloads: Media, multipart and resumable uploads, ranged downloads, exports of Google Docs Editors files and download operations.
Determinism and reset
Two things do not repeat from a reset: the change feed’s page tokens, which keep counting, and a resumable upload’s session URI. Reset and determinism covers reset, the clock and the RNG.
A changes.list that passes its token, page-size and scope checks moves the clock one millisecond, even with an empty page or a 400 for fields. POST /_rystic/reset leaves one user and no files, as an empty boot does.
Limitations
Known issues.
- On a My Drive file,
files.downloadreturns 404 to every user but the owner unless a scenario seeded their grant. On a seeded file,permissions.listandfiles.downloadstill go by a grant afterpermissions.updateorpermissions.deletechanges it. After an ownership transfer,ownersstill names the previous owner and every read lists both users asowner. files.listwithq=name < 'x'returns 400invalid, where Drive returns 500internalError.DELETE /drive/v3/files/trashpermanently deletes a collaborator’s file inside the caller’s trashed folder, where Drive deletes only the caller’s own files.- A folder’s owner can’t read a collaborator’s file in their own folder (404, and
'<folder>' in parentsleaves it out), and that file lists two owners. - A link-only file (
anyonewithallowFileDiscovery: false) shows up in any user’sfiles.list. starredis one flag shared by every user, a reader or commenter can’t star a file, and starring bumpsversionandmodifiedTime.files.copypoints the copy’swebViewLink,webContentLinkandthumbnailLinkat the source, ignores an id fromgenerateIds, and leaves a reader’s copy with no parent.comments.getnever returnsreplies.- What deleting or trashing
rootreturns is unconfirmed, though Drive reportscanDeleteandcanTrashtrue on the root. - A media upload onto a folder returns 200 and leaves the folder unchanged, as Drive does; what Drive does with the uploaded bytes is unconfirmed.
- A resumable upload checks its metadata when the last byte arrives, where Drive refuses bad metadata at the initiate; its session never expires; and its 308 responses carry no
X-Range-MD5orX-Goog-Running-Hashheader. - The operation
files.downloadreturns never expires:operations.getreturns it for as long as you can read the file, while Drive documents that an operation expires 24 hours after it starts. drives.createwith arequestIdyou used on a drive that has since been deleted creates a new drive, where Drive still returns 409teamDriveAlreadyExists.- Deleting a shared drive right after adding a file to it always returns 403
cannotDeleteResourceWithChildren, where Drive can briefly allow it. - A user who is not a member of a shared drive but holds a direct grant on a file inside it reads the file’s
capabilities.canReadDriveastrue, where Drive returnsfalse. That grant’s permission also leaves outteamDrivePermissionDetails. drives.getanddrives.listleave outrestrictions,colorRgbandbackgroundImageLink. Thedriveinside a drive change leaves outbackgroundImageLink,colorRgb,restrictions,capabilities,createdTimeandhidden.drives.listignoresfieldsand returns whole drives, and creating or updating a drive returnskind,idandnamewhateverfieldsnames, where Drive returns the fields you select.
Beyond the known issues, 19 of the 66 operations in the published spec are not served, 81 documented responses have no test yet and 189 behaviors are not modeled. The details follow.
Show all limitations
Not served. 19 of the 66 operations in the published spec are not served. Calling one of these routes returns 501, unless a served route takes its path.
- changes, 2 of 3 served:
POST /drive/v3/changes/watch - files, 15 of 19 served:
GET /drive/v3/files/generateCseToken,GET /drive/v3/files/{fileId}/listLabels,POST /drive/v3/files/{fileId}/modifyLabels,POST /drive/v3/files/{fileId}/watch - Not served at all: accessproposals (3), approvals (8), apps (2), channels (1)
Not tested. 831 tests compare the simulator with the real service. 81 documented responses have no test yet, and 14 of them need a credential our test account doesn’t hold (403 ×14). The other 67:
| Operation | Status | Why |
|---|---|---|
DELETE /drive/v3/files/trash | 400 | a well-formed request does not provoke it |
DELETE /drive/v3/files/trash | 429 | no request a client sends provokes it |
DELETE /drive/v3/files/trash | 500 | no request a client sends provokes it |
DELETE /drive/v3/files/{fileId} | 429 | no request a client sends provokes it |
DELETE /drive/v3/files/{fileId} | 500 | no request a client sends provokes it |
DELETE /drive/v3/files/{fileId}/comments/{commentId} | 429 | no request a client sends provokes it |
DELETE /drive/v3/files/{fileId}/comments/{commentId} | 500 | no request a client sends provokes it |
DELETE /drive/v3/files/{fileId}/comments/{commentId}/replies/{replyId} | 429 | no request a client sends provokes it |
GET /drive/v3/about | 429 | no request a client sends provokes it |
GET /drive/v3/about | 500 | no request a client sends provokes it |
GET /drive/v3/changes | 400 | a well-formed request does not provoke it |
GET /drive/v3/files | 429 | no request a client sends provokes it |
GET /drive/v3/files | 500 | no request a client sends provokes it |
GET /drive/v3/files/generateIds | 429 | no request a client sends provokes it |
GET /drive/v3/files/generateIds | 500 | no request a client sends provokes it |
GET /drive/v3/files/{fileId} | 429 | no request a client sends provokes it |
GET /drive/v3/files/{fileId} | 500 | no request a client sends provokes it |
GET /drive/v3/files/{fileId}/comments | 429 | no request a client sends provokes it |
GET /drive/v3/files/{fileId}/comments | 500 | no request a client sends provokes it |
GET /drive/v3/files/{fileId}/comments/{commentId}/replies | 429 | no request a client sends provokes it |
| … and 47 more |
1 recorded test is not run.
8 variant requests of tested responses are not sent: DELETE /drive/v3/drives/{driveId} (204), DELETE /drive/v3/files/{fileId}/permissions/{permissionId} (404), GET /drive/v3/files/{fileId}/permissions/{permissionId} (404), PATCH /drive/v3/files/{fileId}/permissions/{permissionId} (404).
Not modeled. Behavior the simulator does not model, by operation:
- Documented statuses not reproduced: 400 (2 operations), 404 (2 operations), 500 (1 operation).
- Cross-actor access lag after a delete (about 1.8 s before actor B’s read turns 404) is a property of the reading operation, not of this delete. (
DELETE /drive/v3/files/{fileId}/permissions/{permissionId}) - The page token’s grammar, ordering guarantees across pages and validity window are opaque; only the refusal of a token the service did not issue is modeled. (
GET /drive/v3/drives) - includeLabels/labelInfo and includePermissionsForView are not modeled in the 200 body shape. (
GET /drive/v3/files) - The exact 500 backendError body: the BackendError response declares only the ErrorResponse schema with no sample. (
GET /drive/v3/files/{fileId}/comments/{commentId}/replies) - The description warns the list may be incomplete for files with a large revision history (frequently edited Docs/Sheets/Slides); which revisions are omitted is not specified. (
GET /drive/v3/files/{fileId}/revisions) - Whether pageSize=0 or a malformed pageToken is refused (400) or ignored is not documented; the description only states values above 1000 are coerced to 1000. (
GET /drive/v3/files/{fileId}/revisions) - Whether the suffix Range form (bytes=-5) and a multi-range request behave as the single prefix range does is documented only for bytes=-5 and is not separately modeled. (
GET /drive/v3/files/{fileId}?alt=media) - Only the move itself is modeled. (
PATCH /drive/v3/files/{fileId}) - includeLabels / includePermissionsForView and the labelInfo projection they populate are unmodeled; the Label and Permission sub-resources are out of scope. (
PATCH /drive/v3/files/{fileId}) - Whether a non-JSON Content-Type label is refused or ignored. (
POST /drive/v3/files) - The revisionId variant: with revisionId the downloadUri becomes…/files/
<id>/revisions/<revisionId>?alt=media&source=downloadUrl, and an unknown revisionId is not checked. (POST /drive/v3/files/{fileId}/download) - A plain application/json body sent to uploadType=multipart is stored as the bytes of an ‘Untitled’ application/json file in My Drive root rather than refused. (
POST /upload/drive/v3/files?uploadType=multipart) - … and 174 more
By design.
- Search and field selectors.
files.listtakes a subset of Drive’s search terms, and some routes ignorefields(Search and field selectors).
Release notes: Changelog