boredProjects
boredProjects

Reputation: 343

How do I connect my react website to google drive to store uploaded files

I have a file upload in place however I want to go ahead and send my files to google drive to be stored however I'm not sure where to start and everything I've seen so far online has been a bit confusing. Does anyone have any tips?

Upvotes: 1

Views: 2502

Answers (1)

Daniel
Daniel

Reputation: 3725

This is a pretty broad question, your best bet is just to read Google's documentation and code samples to understand how the process works.

  1. Learn how Google uses OAuth 2.0 to authorize APIs. This involves creating a Google Cloud Platform project to generate the access credentials. The Get Started guide contains the steps to create this project and set it up.

  2. With the credentials you can generate a token to authorize your app to access Drive. Since you said that you are already uploading the files you'll probably want to do this on the back-end. There's a general sample for using OAuth with web applications and for something more specific you can check out the Drive examples.

  3. You could also choose to do it on the front-end. Google has a different guide for that, and the code sample in Erwin's comment can help you as well to follow up after you have the authorization token. There's another guide in Github referenced in that link that can also help you generate the auth token.

My recommendation is to first really learn how OAuth works, here's a great question about it. Then use the links above to understand how Google uses it and their required steps, then try to implement it yourself little by little and look for, or ask specific questions if you get stuck in some step. Understanding the process is key to make it easier for yourself so you'll need to dedicate some time into studying it.

Upvotes: 3

Related Questions