-1

So, I have a file stored on my drive and I'm building a web app using javascript that needs to read the file to function. what is the simplest way of doing this?

I tried a dozen methods but it always requires user verification for some reason. I don't want the user to verify, its not their files, they're mine.

Shahagi
  • 11

1 Answers1

1

The issue you are probably having with the methods that you have used has to do with user premissions. There is a diffcence between public and private data.

  • Public data is not owned by anyone anyone can see it. Youtube video search for example
  • private data would be data that is owned by a user. Files on my google drive account

In order to access private user data you need the users permission to do that. The methods you are currently using are called Oauth2 authentication where a user is prompted for their consent to access their data.

Assuming that i am understanding you correctly. What you want to do is access your own data and show that to users. Normally what i would say would be that you should be using a service account. Service accounts are like dummy users who can be granted access to data. For example you could take the service account email address and share a folder on your google drive account with the service account it will then be pre authorized and when ever you use it to authenticate you will have access to those files.

The main problem here is that JavaScript does not support service account authentication you need to use a server sided programming language to use it. OAuth2ServiceAccount

Public File

If you change the permissions on the file and make it public. You can then use an api key to access it. You will not be able to update it using an api key though. You will only be able to read it.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • and this is the case even if the file has a public link? i made it public in the drive (although I assumed it wasn't that simple). – Shahagi Jan 16 '19 at 14:34
  • Well if you made the file public you could use an API key to access it. But you could only read it you cant make any changes. – Linda Lawton - DaImTo Jan 16 '19 at 14:49
  • How is that done? I couldn't find a decent tutorial referring to public files. – Shahagi Jan 16 '19 at 15:42
  • and if i have the file's downloadUrl (the real one, not the link shown on the drive, from https://doc-0g-0g-docs.googleusercontent.com) could I just use a GET request? – Shahagi Jan 16 '19 at 15:47