You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This backend supports per-user Google Drive OAuth2 for resume-copy automation. It does **not** replace the app's JWT auth flow; users stay authenticated with the existing bearer token, and Google is connected separately with `POST /api/v1/google-drive/oauth/start`.
218
+
219
+
### Required Google Cloud setup
220
+
221
+
1. Create a Google Cloud OAuth client for a web application.
222
+
2. Enable the **Google Drive API**.
223
+
3. Add the backend callback URL as an authorized redirect URI. Example local value:
|`GOOGLE_DRIVE_CLIENT_ID`| Yes | Google OAuth client ID |
230
+
|`GOOGLE_DRIVE_CLIENT_SECRET`| Yes | Google OAuth client secret |
231
+
|`GOOGLE_DRIVE_REDIRECT_URI`| Yes | Backend callback URL registered in Google Cloud |
232
+
|`GOOGLE_DRIVE_OAUTH_COMPLETE_URL`| Yes | Frontend page that receives the final `status` and `message` query params after OAuth finishes |
233
+
|`GOOGLE_DRIVE_AUTHORIZATION_URI`| No | Override Google authorization endpoint |
234
+
|`GOOGLE_DRIVE_TOKEN_URI`| No | Override Google token endpoint |
235
+
236
+
### OAuth flow expectations
237
+
238
+
1. Frontend calls `POST /api/v1/google-drive/oauth/start` with the user's JWT bearer token.
239
+
2. Backend creates a short-lived OAuth state tied to that authenticated user and returns:
240
+
-`authorizationUrl`
241
+
-`state`
242
+
-`redirectUri`
243
+
-`scopes`
244
+
3. Frontend opens `authorizationUrl` in a new tab or popup.
245
+
4. Google redirects back to `GET /api/v1/google-drive/oauth/callback`.
246
+
5. Backend exchanges the authorization code for user-scoped Drive credentials, stores them, and redirects the browser to `GOOGLE_DRIVE_OAUTH_COMPLETE_URL` with:
247
+
-`status=success|error`
248
+
-`message=<url-encoded message>`
249
+
250
+
### Scope used
251
+
252
+
-`https://www.googleapis.com/auth/drive`
253
+
254
+
This scope is used so the backend can validate user-selected Drive folders, read chosen Google Docs metadata, create vacancy subfolders, and copy Google Docs files on behalf of the authenticated user.
255
+
256
+
### Supported files
257
+
258
+
- Base resumes must be **Google Docs** (`application/vnd.google-apps.document`).
259
+
- The root folder must be a **Google Drive folder**.
260
+
- The frontend Gemini button that opens `https://gemini.google.com/gem/f8ed7c14b062` is frontend-only and does not require a backend endpoint.
261
+
262
+
### Resume copy behavior
263
+
264
+
When the frontend later calls `POST /api/v1/google-drive/applications/{applicationId}/resume-copies`:
265
+
266
+
1. Backend verifies the current user owns the application.
267
+
2. Backend refreshes the user's Google access token if needed.
268
+
3. Backend verifies the configured root folder still exists and is a folder.
269
+
4. Backend finds or creates a vacancy subfolder under that root folder using the application identity.
270
+
5. Backend copies the selected base Google Doc into that subfolder.
271
+
6. Backend renames the copy with an `APP-<application-uuid>` prefix plus vacancy context.
272
+
7. Backend returns a Google Docs web URL for the copied file.
0 commit comments