Skip to content

Commit a75b003

Browse files
committed
Google Drive Access re-requested and fixed
1 parent de45273 commit a75b003

14 files changed

Lines changed: 23 additions & 19 deletions

src/cloud/__tests__/GoogleDriveProvider.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ describe('GoogleDriveProvider Property Tests', () => {
330330
provider: 'googledrive',
331331
accessToken: 'valid-token',
332332
expiresAt: new Date(Date.now() + 3600000), // 1 hour from now
333-
scope: 'https://www.googleapis.com/auth/drive.file'
333+
scope: 'https://www.googleapis.com/auth/drive'
334334
});
335335
});
336336

src/cloud/config/demo-credentials.example.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export const GOOGLE_DRIVE_CONFIG = {
1818

1919
// OAuth scopes required by EasyEditor
2020
SCOPES: [
21-
'https://www.googleapis.com/auth/drive.file', // Create, edit, delete files the app creates
22-
'https://www.googleapis.com/auth/drive.readonly' // Read all files (needed to discover manually uploaded files)
21+
'https://www.googleapis.com/auth/drive', // Full drive access for managing files across sessions
2322
],
2423

2524
// Discovery document for Google Drive API v3

src/cloud/config/google-credentials.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,14 @@ export const GOOGLE_DRIVE_CONFIG: GoogleDriveConfig = (() => {
201201
REDIRECT_URI: envConfig.REDIRECT_URI,
202202

203203
// OAuth scopes required by EasyEditor
204+
// NOTE: We use the full 'drive' scope instead of 'drive.file' + 'drive.readonly'
205+
// because drive.file only grants write access to files created by the *current*
206+
// OAuth session. When a user disconnects and reconnects, the per-file grants
207+
// are lost and previously created files become read-only (403 appNotAuthorizedToFile).
208+
// The full 'drive' scope ensures the app can always read/write/delete files in
209+
// its Easyeditor folder, regardless of which OAuth session created them.
204210
SCOPES: [
205-
'https://www.googleapis.com/auth/drive.file', // Create, edit, delete files the app creates
206-
'https://www.googleapis.com/auth/drive.readonly' // Read all files (needed to discover manually uploaded files)
211+
'https://www.googleapis.com/auth/drive',
207212
],
208213

209214
// Discovery document for Google Drive API v3

src/cloud/providers/GISGoogleDriveProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class GISGoogleDriveProvider implements CloudProvider {
3838
readonly icon = '🗂️';
3939

4040
private clientId: string;
41-
private scope: string = 'https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.readonly';
41+
private scope: string = 'https://www.googleapis.com/auth/drive';
4242
private tokenClient: any = null;
4343
private isGISLoaded: boolean = false;
4444

src/cloud/providers/GoogleDriveProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class GoogleDriveProvider implements CloudProvider {
3939

4040
private clientId: string;
4141
private apiKey: string;
42-
private scope: string = 'https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.readonly';
42+
private scope: string = 'https://www.googleapis.com/auth/drive';
4343
private isGapiInitialized: boolean = false;
4444
private gapiInstance: any = null;
4545

src/cloud/providers/MockGoogleDriveProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class MockGoogleDriveProvider implements CloudProvider {
1919
provider: this.name,
2020
accessToken: 'fake-access-token-' + Date.now(),
2121
expiresAt: new Date(Date.now() + 3600000), // 1 hour from now
22-
scope: 'https://www.googleapis.com/auth/drive.file'
22+
scope: 'https://www.googleapis.com/auth/drive'
2323
};
2424

2525
// Save the fake credentials

src/cloud/providers/SimpleGoogleDriveProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class SimpleGoogleDriveProvider implements CloudProvider {
3636

3737
private clientId: string;
3838
private apiKey: string;
39-
private scope: string = 'https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.readonly';
39+
private scope: string = 'https://www.googleapis.com/auth/drive';
4040

4141
constructor(clientId?: string, apiKey?: string) {
4242
this.clientId = clientId || GOOGLE_DRIVE_CONFIG.CLIENT_ID;

src/cloud/providers/TauriGoogleDriveProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class TauriGoogleDriveProvider implements CloudProvider {
3636
readonly icon = '🗂️';
3737

3838
private clientId: string;
39-
private scope: string = 'https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.readonly';
39+
private scope: string = 'https://www.googleapis.com/auth/drive';
4040
private redirectUri: string = 'http://localhost:8080/oauth/callback';
4141

4242
constructor(clientId?: string, _apiKey?: string) {

src/services/oauth/__tests__/GoogleOAuthProvider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('GoogleOAuthProvider', () => {
3737

3838
// Scope should be an array with Google Drive scope
3939
expect(Array.isArray(provider.scope)).toBe(true);
40-
expect(provider.scope).toContain('https://www.googleapis.com/auth/drive.file');
40+
expect(provider.scope).toContain('https://www.googleapis.com/auth/drive');
4141

4242
// Properties should be defined and consistent
4343
expect(typeof provider.name).toBe('string');
@@ -83,7 +83,7 @@ describe('GoogleOAuthProvider', () => {
8383

8484
// Scope should contain Google Drive scope
8585
const scope = params.get('scope');
86-
expect(scope).toContain('https://www.googleapis.com/auth/drive.file');
86+
expect(scope).toContain('https://www.googleapis.com/auth/drive');
8787
}
8888
),
8989
{ numRuns: 100 }

src/services/oauth/__tests__/OAuth.workflow-integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('OAuth Workflow Integration Tests', () => {
3333
'google': {
3434
clientId: 'google-test-client-id',
3535
enabled: true,
36-
scope: ['https://www.googleapis.com/auth/drive.file']
36+
scope: ['https://www.googleapis.com/auth/drive']
3737
},
3838
'github': {
3939
clientId: 'github-test-client-id',
@@ -602,7 +602,7 @@ describe('OAuth Workflow Integration Tests', () => {
602602
displayName: 'Google',
603603
authorizationUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
604604
tokenUrl: 'https://oauth2.googleapis.com/token',
605-
scope: ['https://www.googleapis.com/auth/drive.file'],
605+
scope: ['https://www.googleapis.com/auth/drive'],
606606
clientId: 'valid-google-client-id'
607607
},
608608
{

0 commit comments

Comments
 (0)