Reputation: 665
My app requests the 'https://www.googleapis.com/auth/drive.readonly' permission from a user. When the app gets a Google access token, a url is built to access a user selected Google Slides presentation preview, something like:
https://docs.google.com/presentation/d/1WADAfZShdqdYKgae8C9LdpYlPgf2qjoZD2jjKln4F3M/embed?rm=minimal&access_token=ya29.....
This works great to view the presentation, but if a video is used on a slide, then follow error shows:
Since my app is requesting full read access to a user's Google Drive, and the video in question is in the user's Google Drive, why is this happening?
Upvotes: 0
Views: 370
Reputation: 2342
This is happening because you still have to let other users have access to your video itself, therefore you need to share it to them like you would do it with any other kind of file inside your Drive.
To do it programmatically, you will need to use the Drive API and build a request in the Files: update enpoint like this:
[
{
'type': 'user',
'role': 'writer',
'emailAddress': '[email protected]'
}, {
'type': 'domain',
'role': 'writer',
'domain': 'example.com'
}
]
For what I could understand now. To be able to see the video, do the following:
1) Right-click on the video.
2) Click Share.
3) Click "Advanced" (It is in the right-bottom corner).
4) Click "Change...".
5) Choose "On -Anyone with the link" and set the access as "Can Edit".
When you use the "access_token" query parameter Google Slide is going to search for the video's URL in the Driver, which you have to set shareable permissions to the video.
Images can be accessible from anyone who has access to the presentation as the doc says:
An URL to an image with a default lifetime of 30 minutes. This URL is tagged with the account of the requester. Anyone with the URL effectively accesses the image as the original requester. Access to the image may be lost if the presentation's sharing settings change.
Videos have to have the sharing settings configure as the doc says:
An URL to a video. The URL is valid as long as the source video exists and sharing settings do not change.
Notice the difference between the two here: Anyone with the URL effectively accesses the image as the original requester.
I am updating my answer because I came across this, which states authorizing your requests through the access token query parameter to connect to the Drive API will be deprecated starting January 1, 2020.
Therefore your requests now will need to be made using an HTTP header. My answer should be considered a workaround because it will be deprecated soon.
You can find more info about the Slides API and Drive API in the following links:
Upvotes: 1
Reputation: 1565
Although you have stored your video in the same drive location alongside your presentation, I guess it might not be accessiable when it is "embedded within your slides".
However, you would be able to access the video if you use the same access token to see the video alone.
It would be better to store videos separately, embedded them in your presentation and then access them using their respective scopes instead.
if you choose to take this route then,
I think you need to allow the following scopes as well to access your video from the presentation viz drive.photos.readonly, youtube.force-ssl respectively. Alongside your other drive scopes, provided you have stored videos in either of the 2 ways mentioned below. Hence, at the time of access_token request, use the relevant scopes and get the access token and use the same for accessing your resources at a later point in time.
2 options,
When using Drive API
https://www.googleapis.com/auth/drive.photos.readonly
View the photos, videos and albums in your Google Photos
When using Youtube
https://www.googleapis.com/auth/youtube.force-ssl See, edit, and permanently delete your YouTube videos, ratings, comments and captions
Google API documentation -
https://developers.google.com/identity/protocols/googlescopes
Upvotes: 0