-1

I'm developing an web application right now.

What I have so far in the app is this:

<input type="text" id="textToSendToMyGoogleDrive"/>
<button id="upload file to google drive"> Send </button>

This application has a domain, so every one can go to this application from their computer.

What I want to do is when any user put text in the input, and clicks the button, it will make a txt file and send it into my google drive account.

So I have two problems here:

  1. How to take the text and make from it a txt file.

  2. Send the file to specific google drive account.

Problem number 2 is a problem because I have looked every where in the google drive API, and all I could found is some methods to upload files to the user's google drive, and not to mine. So I tried to search out how to "sign in" the user when he is in the application to my google drive, and I could not find a solution.

If I was not clear on the problems, comment me.

Thank you!

OmerLevi
  • 119
  • 1
  • 8

1 Answers1

0

I'am not a expert but correct me if I'am wrong. I think there is a problem with your approach. how about sending your text content as a request parameter to the backend and save it as a .txt from there.

I am suggesting this because, let say you save your file with text content in users computer as described in here.

next step would be to access it from the browser and save it in the google drive. if you planning to do it from the front end without a backend, you have to expose your google credentials to every user.

Before that you wont be able to access a local file from users computer directly from the browser. because most browsers wont allow you to do that. so please change your approach to this.

Sankha Karunasekara
  • 1,636
  • 18
  • 19
  • Thank you for your answer. I did not understand something. Why if it will expose my google account to every user? – OmerLevi Nov 03 '18 at 12:42
  • normally in the backend what we do is, we use our refresh token(valid for 6 month or so) to generate a access token (short lived). then we send access token to user and he will upload a file using that token as a credential. if you were to generate access token from the front end( I am not sure you can do that) you must have the refresh token. refresh token is a sensitive information, you don't wont to expose that. – Sankha Karunasekara Nov 03 '18 at 12:59
  • I got you. But could not I just hide this info from the front end? So no body can see it? – OmerLevi Nov 03 '18 at 13:05
  • oh never do that buddy..! that is huge risk to take. where are you planing to host your application? – Sankha Karunasekara Nov 03 '18 at 13:15
  • heroku support node.js right? you can use it for uploading part. use this link. https://developers.google.com/drive/api/v3/manage-uploads – Sankha Karunasekara Nov 03 '18 at 13:39