How I replaced GTLR with a lean REST setup—token-based Google Drive integration using URLSession, safer secrets, and fewer moving parts.
GTLR is gone from my stack. I rebuilt file list, upload, and metadata calls with token-based Google Drive integration using pure REST and URLSession
. The result: smaller binaries, clearer errors, and auth I actually understand. This post shows the moving pieces, pitfalls, and a copy-paste checklist you can apply today. For layout sanity while rebuilding screens, I leaned on Golden Scaling in Practice—pre-deciding anchors kept my UI and my head calm during refactors.
Libraries hide complexity—until they don’t. A direct REST approach gives you explicit control over scopes, refresh timing, and retries. With a short AuthService
, I trade magical “it works” for transparent calls I can reason about. See my earlier context in LifeOS Dev Log: Drive Tokens & List/Grid Toggle for how this started.
UserDefaults
or the document.Authorization: Bearer <access_token>
./drive/v3/files
for list/search, /upload/drive/v3/files
for media.drive.file
beats drive
).expires_in
and refresh proactively at ~80% of lifetime.GET https://www.googleapis.com/drive/v3/files?q=name contains 'doc'&fields=files(id,name,mimeType,modifiedTime,size)
POST https://www.googleapis.com/upload/drive/v3/files?uploadType=media
POST https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart
POST https://oauth2.googleapis.com/token
The official references are clear and current: Drive API (REST) Overview and Google Identity: OAuth 2.0.
Token work is plumbing; users feel rhythm. Anchor your headline on 3/5, your primary action (Upload / Connect) on 5/8, and stick to one gutter (8/13/21). These small rules keep “settings” screens from feeling like a spreadsheet.
drive.file
; escalate only if required.fields=
to exactly what you render; faster and cheaper.HTTPClient
with request/response logging (redacted).Start by swapping your file list screen to REST calls behind an AuthService
. If it feels good, move uploads and metadata next. When you hit the first 401 in the wild, you’ll be glad you understand the flow. Download the starter snippet for URLSession + refresh and make your Drive calls boring—in the best way.
- randomblink