0

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: enter image description here

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?

Adam
  • 655
  • 1
  • 6
  • 19

2 Answers2

1

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': 'user@example.com'
  }, {
    'type': 'domain',
    'role': 'writer',
    'domain': 'example.com'
  }
]

Edit

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.

Update

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.

Docs

You can find more info about the Slides API and Drive API in the following links:

alberto vielma
  • 2,302
  • 2
  • 8
  • 15
  • The video is in the current user's drive, with the presentation. It's not a shared video. This error only shows when the presentation is accessed using the 'access_token' query param. – Adam Nov 19 '19 at 14:05
  • Thank you, that worked. So is that done by design? That seems like a bug. If I insert an image into the presentation from my drive, it shows fine without being shared publicly, just videos have this issue. – Adam Nov 19 '19 at 19:12
  • I edited my answer explaining the differences between the videos and images – alberto vielma Nov 20 '19 at 09:09
0

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

forkdbloke
  • 1,505
  • 2
  • 12
  • 29
  • Even with the following scopes, the "Request access" button still shows. 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/drive.photos.readonly', 'https://www.googleapis.com/auth/youtube.force-ssl' – Adam Nov 21 '19 at 16:50
  • Adam, did you get the resolution as specified by alberto? Did you get time to check it out! – forkdbloke Nov 21 '19 at 17:06
  • Yes, Alberto's solution works, but I'm hoping for something more automated that didn't require permission adjustment on videos. – Adam Dec 09 '19 at 14:29