Tested and used the Google API for uploading and downloading the files from Googledrive using Oauth.
- So in google cloud console, You must first enable the API service you want to use.
- After enabling the API in API and Services , create your credentials with callback url and all the scopes you may need for your project.
- Google will provide you Client ID and Client Secret for Oauth and API key for public APIs.
- Now using the
googleapis
npm library we can create an Oauth client and by setting the refresh token we will make it a client for which we generated the access and refresh token. - Google does not need
accessToken
to validate a user but the refresh token and idk why? - Now you can also get the
accessToken
by thegetAccessToken()
method on the client. - Your client is now generated do the further task as you need.
**This Explanation is totally for my understanding! Thank you!! **
To run this project, you will need to add the following environment variables to your .env file
CLIENT_ID
CLIENT_SECRET
And optional
MONGODB_URL
Because the tokens do not change on the requests!!