How to get refresh token for google drive api
Go to https://developers.google.com/oauthplayground. (Make sure you added this URL to your Authorized redirect URIs in the previous step.) In the top right corner, click the settings icon, check "Use your own OAuth credentials" and paste your Client ID and Client Secret.
In step 1 on the left, scroll to "Drive API v3", expand it and check the first drive scope.
Click "Authorize APIs" and allow access to your account when prompted. There will be a few warning prompts, just proceed.
When you get to step 2, check "Auto-refresh the token before it expires" and click "Exchange authorization code for tokens".
When you get to step 3, click on step 2 again and you should see your refresh token.