Request new token for Google Drive API


I am creating a system that programmatically store files in Google Drive whenever the timer was triggered. (This drive is for admin, not for user side. Unlike the GDriveConnector-Demo)

For starters, I have a screen that lets the Admin input the API key, Client ID, and Client Secret, then let them authenticate the system to store files in the Drive. After that, system will store the credentials to Site prop.

However, when the token expired, they need to authenticate again to be able to renew the tokens.

How will I be able to renew the token? (Or is it possible programmatically?)

If this is possible, I am planning to insert this function whenever the timer was execute, I will check first if the token is expired, if yes, then renew token. The only problem is that I dont know how to renew this token.

I keep getting this error 'cos I guess token is expired? Or maybe authentication doesn't reach this part of the system (Since this is a function triggered by timer in different module)?

I hope someone can help me.

Thanks in advance!

Rank: #1356


You could use refresh tokens to acquire new access tokens without needing the user to authenticate again.

You can find more information here.

Miguel Sousa