Closed meet1919 closed 2 years ago
@meet1919 it looks like the reason The authenticated user has not granted the app 762308209922 write access to the file 1PA5VXeQcWV2s8YRk0diqa2nWHgPzR1iS
.
You check that the oauth_scope
is set correctly (default value should be fine).
Feel free to reopen if you this is a bug.
I havent changed anything on the oauth scope in the google developer console so it should be default.
I have enabled this but the error still persists.
@meet1919 where did you get this screenshot? (is it part of GCP, can you share what part it is?)
have you tried to remove the credentials file that got created and go through the auth process one more time now?
Hey, actually this screenshot was sent by my client, I told him to add scopes for google drive API, he did this and sent me a new client_sectrets.json
. I deleted mycreds.txt
and credentials.json
files, authenticated once again, and still got the same error.
Hey, these are the scopes I have added and still I cant delete the file and folder. Pydrive2
is throwing the same error.
pydrive2.files.ApiRequestError: <HttpError 403 when requesting https://www.googleapis.com/drive/v2/files/1PA5VXeQcWV2s8YRk0diqa2nWHgPzR1iS?supportsAllDrives=true returned "The authenticated user has not granted the app 524422223106 write access to the file 1PA5VXeQcWV2s8YRk0diqa2nWHgPzR1iS". Details: "[{'message': 'The authenticated user has not granted the app 524422223106 write access to the file 1PA5VXeQcWV2s8YRk0diqa2nWHgPzR1iS', 'domain': 'global', 'reason': 'fileAccess', 'location': 'Authorization', 'locationType': 'header'}]">
Please HELP me......
@meet1919 can this user (the authenticated one) can try to go and delete this file manually (via Google Drive UI)? Btw, are you trying to delete a file or a directory?
@shcheklein The user (the authenticated one) is one whose drive has been automated. The developer app in google has also been created from the same google account. I want to delete both files and directories. So yes, the user can go and manually delete everything permanently. Also, I tried to move the folder to the trash but again the same error. BTW, the app is able to delete the file that has been just uploaded by the app.
One more thing.
file1 = drive.CreateFile({'id': file_id})
document = file1.GetContentIOBuffer()
print(document.read())
I was getting the document file and reading it. But I got the same kind of error.
pydrive2.files.ApiRequestError: <HttpError 403 when requesting https://www.googleapis.com/drive/v2/files/1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa?alt=media returned "The authenticated user has not granted the app 524422223106 read access to the file 1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa". Details: "[{'domain': 'global', 'reason': 'fileAccess', 'message': 'The authenticated user has not granted the app 524422223106 read access to the file 1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa', 'locationType': 'header', 'location': 'Authorization'}]">
I don't understand this. Despite giving sufficient permissions, why I am still getting these errors?
For more reference :
Below is the Metadata for the document file. You can see clearly that it can be shared, read, deleted, trashed, etc but it seems like the user which has authenticated has denied the permission to do so when logging in.
GoogleDriveFile({'id': '1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa', 'kind': 'drive#file', 'etag': '"MTY1NTM3NTkxODAwMA"', 'selfLink': 'https://www.googleapis.com/drive/v2/files/1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa', 'webContentLink': 'https://drive.google.com/uc?id=1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa&export=download', 'alternateLink': 'https://drive.google.com/file/d/1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa/view?usp=drivesdk', 'embedLink': 'https://drive.google.com/file/d/1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa/preview?usp=drivesdk', 'iconLink': 'https://drive-thirdparty.googleusercontent.com/16/type/text/plain', 'hasThumbnail': True, 'thumbnailVersion': '1', 'title': 'Download.txt', 'mimeType': 'text/plain', 'labels': {'starred': False, 'hidden': False, 'trashed': False, 'restricted': False, 'viewed': True, 'modified': True}, 'copyRequiresWriterPermission': False, 'createdDate': '2022-06-25T05:15:15.562Z', 'modifiedDate': '2022-06-16T10:38:38.000Z', 'modifiedByMeDate': '2022-06-16T10:38:38.000Z', 'lastViewedByMeDate': '2022-06-25T05:15:15.562Z', 'markedViewedByMeDate': '1970-01-01T00:00:00.000Z', 'version': '3', 'parents': [{'kind': 'drive#parentReference', 'id': '1yp92Zs_QLDBUcmYzB0xFGL9NyNF6h7t_', 'selfLink': 'https://www.googleapis.com/drive/v2/files/1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa/parents/1yp92Zs_QLDBUcmYzB0xFGL9NyNF6h7t_', 'parentLink': 'https://www.googleapis.com/drive/v2/files/1yp92Zs_QLDBUcmYzB0xFGL9NyNF6h7t_', 'isRoot': False}], 'userPermission': {'kind': 'drive#permission', 'etag': '"gpvPbgnlGt5w_WuGhnIOwKgdhZI"', 'id': 'me', 'selfLink': 'https://www.googleapis.com/drive/v2/files/1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa/permissions/me', 'role': 'owner', 'type': 'user', 'pendingOwner': False}, 'permissions': [{'kind': 'drive#permission', 'etag': '"eecoo-GSZXUSrP9HyBCUFngGdbw"', 'id': '07347475262663668620', 'selfLink': 'https://www.googleapis.com/drive/v2/files/1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa/permissions/07347475262663668620', 'name': 'Meet Gondaliya', 'emailAddress': 'meetgondaliya1999@gmail.com', 'domain': 'gmail.com', 'role': 'writer', 'type': 'user', 'photoLink': 'https://lh3.googleusercontent.com/a-/AFdZucrJrswrp6zf-TkdVW_1Mapr1d70_dQleTu1uIvTBQ=s64', 'deleted': False, 'pendingOwner': False}, {'kind': 'drive#permission', 'etag': '"4nVgIVFL0-GuNRY9Kxn9zBOXG4Q"', 'id': '08334774270429841139', 'selfLink': 'https://www.googleapis.com/drive/v2/files/1ekcNTgfw_2DGLj0_J5pP_rn8JCysRGKa/permissions/08334774270429841139', 'name': 'Eli Hury', 'emailAddress': 'payupfiles@gmail.com', 'domain': 'gmail.com', 'role': 'owner', 'type': 'user', 'photoLink': 'https://lh3.googleusercontent.com/a/default-user=s64', 'deleted': False, 'pendingOwner': False}], 'permissionIds': ['07347475262663668620', '08334774270429841139'], 'originalFilename': 'Download.txt', 'fileExtension': 'txt', 'fullFileExtension': 'txt', 'md5Checksum': '85970f3d0a300553db4a42c5210591b2', 'fileSize': '34', 'quotaBytesUsed': '34', 'ownerNames': ['XYZ'], 'owners': [{'kind': 'drive#user', 'picture': {'url': 'https://lh3.googleusercontent.com/a/default-user=s64'}, 'isAuthenticatedUser': True, 'permissionId': '08334774270429841139', 'emailAddress': 'payupfiles@gmail.com'}], 'lastModifyingUserName': 'XYZ', 'lastModifyingUser': {'kind': 'drive#user', 'displayName': 'XYZ', 'picture': {'url': 'https://lh3.googleusercontent.com/a/default-user=s64'}, 'isAuthenticatedUser': True, 'permissionId': '08334774270429841139', 'emailAddress': 'xyz@gmail.com'}, 'ownedByMe': True, 'capabilities': {'canAcceptOwnership': False, 'canAddChildren': False, 'canAddMyDriveParent': False, 'canChangeCopyRequiresWriterPermission': True, 'canChangeRestrictedDownload': True, 'canChangeSecurityUpdateEnabled': False, 'canComment': True, 'canCopy': True, 'canDelete': True, 'canDownload': True, 'canEdit': True, 'canListChildren': False, 'canModifyContent': True, 'canMoveChildrenWithinDrive': False, 'canMoveItemIntoTeamDrive': True, 'canMoveItemOutOfDrive': True, 'canMoveItemWithinDrive': True, 'canReadRevisions': True, 'canRemoveChildren': False, 'canRemoveMyDriveParent': True, 'canRename': True, 'canShare': True, 'canTrash': True, 'canUntrash': True}, 'editable': True, 'canComment': True, 'canReadRevisions': True, 'shareable': True, 'copyable': True, 'writersCanShare': True, 'shared': True, 'explicitlyTrashed': False, 'appDataContents': False, 'headRevisionId': '0B9kYuwkUinqldHpzTjBDRkNuaVExeEpyU2ZqdnJGRUlLNllBPQ', 'spaces': ['drive'], 'isAppAuthorized': False, 'linkShareMetadata': {'securityUpdateEligible': False, 'securityUpdateEnabled': True}})
More debugging led me to this :
This are the permissions asked during authentication. But here a scope
is missing. See, create, delete all of the file
The UI authentication page isnt asking the permission for seeing, creating, deleting all the files and its just asking for the specific files.
I am not exactly sure why this is happening but I think it might be this :
This shown before asking for the permissions.
From this it looks like that app can't edit, delete, etc any files. Only "specific" files. Something is still missing in the app's settings.
Yeah, delete, edit, etc any files are subject to sensitive scopes and it cant be shown on the consent screen unless the app is verified by google. So there is the problem. Thanks for the support 👍 💯
Code to delete the file:
Error I am getting:
pydrive2.files.ApiRequestError: <HttpError 403 when requesting https://www.googleapis.com/drive/v2/files/1PA5VXeQcWV2s8YRk0diqa2nWHgPzR1iS?supportsAllDrives=true returned "The authenticated user has not granted the app 762308209922 write access to the file 1PA5VXeQcWV2s8YRk0diqa2nWHgPzR1iS". Details: "[{'message': 'The authenticated user has not granted the app 762308209922 write access to the file 1PA5VXeQcWV2s8YRk0diqa2nWHgPzR1iS', 'domain': 'global', 'reason': 'fileAccess', 'location': 'Authorization', 'locationType': 'header'}]">