googleapis / google-api-php-client

A PHP client library for accessing Google APIs
http://googleapis.github.io/google-api-php-client/
Apache License 2.0
9.32k stars 3.52k forks source link

Do I need a refresh token or an access token in order to connect to the Google Drive API? #2508

Closed Kostas-Mavrogalos closed 11 months ago

Kostas-Mavrogalos commented 12 months ago

Greetings, I am aware this is a trivial question, but I couldn't find the answer anywhere on the documentation.

I saw that you need an OAuth consent screen in order for a user to give their consent to access their Drive. However, the last time I worked with a Google API that used an OAuth consent screen, a refresh token was also necessary, which I had to refresh since my project was in "Testing".

With all that in mind, do I need a refresh token in order to connect to a Google Drive through the API?

Thank you in advance

saranshdhingra commented 11 months ago

Hey @Kostas-Mavrogalos You don't need a refresh token to perform API calls. The use of refresh token is only to recreate an expired access token.

If you followed the oauth flow mentioned in the readme, then you can just use the initialized client to make the API calls on the Drive service.

If there's still trouble after that please reopen this ticket with a code snippet that you have tried. Until then I'll be closing this issue.

Regards,