Upload Files into Google Drive using NODE JS Application
By Using Google Drive API and Google Auth2.0
Project on GitHub : https://github.com/dkarandana/OATH2-googleDrive
Getting started
This is a simple authentication tutorial for building a Google Authentication web application using Passport API. It’s a side project that I worked on for education purposes.
Technology and Services
Authentication : Google Auth 2.0
File Uploader : Google Drive API
Authentication middleware : Passport.js
What are we going to build?
- User clicks on login button which redirects to Google OAuth authentication page.
- Once the OAuth has been successfully authenticated to Google, the user will be redirected back to the web application home page.
Passport.js. offers authentication APIs to other OAuth service providers such as Google and Facebook. As an example, I chose to use Twitter as an OAuth service provider.
OATH 2.0 Authentication process
Open Authorization is a standard for granting your web application access to a third-party sign-in service like Twitter, Facebook, or Google, which returns an OAuth token. An OAuth Token is a credential that can be used by an application to access an external service API.
Read more about this protocol https://developers.google.com/identity/protocols/OAuth2
Architecture Diagram
Here is an overview of the architecture diagram which we will be going over in more detail.
Setting up an application Locally
The entire project is available on my Github : https://github.com/dkarandana/OATH2-googleDrive/blob/master/README.md
Application will run on your server by executing $npm run prod
Functionality
The page contains a header with home and login/logout button. Initially, the page will display the welcome page and “login” button. Once the user has authenticated via Google authentication, it will display the username and “logout” button.
Lets log into google drive
Grant Authentication
After granting access Application will redirect you to file upload view
Choose File you need to upload and hit UPLOAD button
Once all completed you will see your files has been successfully uploaded into google Drive.
Reading Materials
Thank you so much for reading this blog post. I hope you found it helpful