Google Drive API read access not granted
up vote
0
down vote
favorite
I am trying to download a random file from a Google Drive using Google Drive API. Although after running the code I got an error message: The user has not granted the app (app_code) read access to the file (filename). How can I grant a read access to the file? I haven't found anything on the internet, and in the API Dashboard either.
# Call the Drive v3 API
results = service.files().list(
pageSize=1000, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', )
rand_item = random.choice(items)
print('{0} ({1})'.format(rand_item['name'], rand_item['id']))
if not items:
print('No files found.')
else:
request = service.files().get_media(fileId=rand_item['id'])
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
print("Download %d%%." % int(status.progress() * 100))
Full code: Pastebin
python python-3.x google-api google-drive-realtime-api
add a comment |
up vote
0
down vote
favorite
I am trying to download a random file from a Google Drive using Google Drive API. Although after running the code I got an error message: The user has not granted the app (app_code) read access to the file (filename). How can I grant a read access to the file? I haven't found anything on the internet, and in the API Dashboard either.
# Call the Drive v3 API
results = service.files().list(
pageSize=1000, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', )
rand_item = random.choice(items)
print('{0} ({1})'.format(rand_item['name'], rand_item['id']))
if not items:
print('No files found.')
else:
request = service.files().get_media(fileId=rand_item['id'])
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
print("Download %d%%." % int(status.progress() * 100))
Full code: Pastebin
python python-3.x google-api google-drive-realtime-api
Perhaps you can check out this documentation on managing sharing. You can also see the permissions guide for additional details about permissions and roles along with the reference guide.
– Jacque
Nov 19 at 6:30
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to download a random file from a Google Drive using Google Drive API. Although after running the code I got an error message: The user has not granted the app (app_code) read access to the file (filename). How can I grant a read access to the file? I haven't found anything on the internet, and in the API Dashboard either.
# Call the Drive v3 API
results = service.files().list(
pageSize=1000, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', )
rand_item = random.choice(items)
print('{0} ({1})'.format(rand_item['name'], rand_item['id']))
if not items:
print('No files found.')
else:
request = service.files().get_media(fileId=rand_item['id'])
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
print("Download %d%%." % int(status.progress() * 100))
Full code: Pastebin
python python-3.x google-api google-drive-realtime-api
I am trying to download a random file from a Google Drive using Google Drive API. Although after running the code I got an error message: The user has not granted the app (app_code) read access to the file (filename). How can I grant a read access to the file? I haven't found anything on the internet, and in the API Dashboard either.
# Call the Drive v3 API
results = service.files().list(
pageSize=1000, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', )
rand_item = random.choice(items)
print('{0} ({1})'.format(rand_item['name'], rand_item['id']))
if not items:
print('No files found.')
else:
request = service.files().get_media(fileId=rand_item['id'])
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
print("Download %d%%." % int(status.progress() * 100))
Full code: Pastebin
python python-3.x google-api google-drive-realtime-api
python python-3.x google-api google-drive-realtime-api
asked Nov 18 at 14:03
Phillip CJ
74
74
Perhaps you can check out this documentation on managing sharing. You can also see the permissions guide for additional details about permissions and roles along with the reference guide.
– Jacque
Nov 19 at 6:30
add a comment |
Perhaps you can check out this documentation on managing sharing. You can also see the permissions guide for additional details about permissions and roles along with the reference guide.
– Jacque
Nov 19 at 6:30
Perhaps you can check out this documentation on managing sharing. You can also see the permissions guide for additional details about permissions and roles along with the reference guide.
– Jacque
Nov 19 at 6:30
Perhaps you can check out this documentation on managing sharing. You can also see the permissions guide for additional details about permissions and roles along with the reference guide.
– Jacque
Nov 19 at 6:30
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Its due to the scope. You only gave metadata.readonly access
Change it to
'https://www.googleapis.com/auth/drive.readonly'
Google Drive API Authorizations
Thanks a lot, it worked.
– Phillip CJ
Nov 19 at 17:28
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Its due to the scope. You only gave metadata.readonly access
Change it to
'https://www.googleapis.com/auth/drive.readonly'
Google Drive API Authorizations
Thanks a lot, it worked.
– Phillip CJ
Nov 19 at 17:28
add a comment |
up vote
0
down vote
accepted
Its due to the scope. You only gave metadata.readonly access
Change it to
'https://www.googleapis.com/auth/drive.readonly'
Google Drive API Authorizations
Thanks a lot, it worked.
– Phillip CJ
Nov 19 at 17:28
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Its due to the scope. You only gave metadata.readonly access
Change it to
'https://www.googleapis.com/auth/drive.readonly'
Google Drive API Authorizations
Its due to the scope. You only gave metadata.readonly access
Change it to
'https://www.googleapis.com/auth/drive.readonly'
Google Drive API Authorizations
answered Nov 19 at 16:32
fcsr
480310
480310
Thanks a lot, it worked.
– Phillip CJ
Nov 19 at 17:28
add a comment |
Thanks a lot, it worked.
– Phillip CJ
Nov 19 at 17:28
Thanks a lot, it worked.
– Phillip CJ
Nov 19 at 17:28
Thanks a lot, it worked.
– Phillip CJ
Nov 19 at 17:28
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361744%2fgoogle-drive-api-read-access-not-granted%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Perhaps you can check out this documentation on managing sharing. You can also see the permissions guide for additional details about permissions and roles along with the reference guide.
– Jacque
Nov 19 at 6:30