S
S
Simon Tis2019-11-13 22:58:57
Google
Simon Tis, 2019-11-13 22:58:57

Oauth2, google how to use refresh token intelligently?

I am writing a simple application using PHP, which periodically, once a day, reads a certain folder on the disk and, finding the last one, reads its data and uses it (for which it doesn’t matter).
I ran into Oauth2 and got confused =(
When I received the authorization code, I changed it to access token and refresh token. As I understand it, the essence here is the following:
access is reusable, but quickly dying (Google lives for an hour)
refresh is almost immortal (a month hike), but one-time "
But I don't really understand the concept of application.
Here I have a script that works every day by cron. For example, it says:
If access is still alive - use it, if not - use refresh and use access again. That's right ?
And what happens when refresh dies? Will I need to re-run the script manually, give Google permission, change the auth code to a pair of access refresh ?
Is it possible to somehow do without it? Maybe on playground google there are jokes in the style - automatic exchange of authorization for refresh and access? I understand that this is not safe, but I don’t need it =(
I found such a thing in the playground
Auto-refresh the token before it expires.
5dcc606122c56762246129.png
But I didn’t even find a use for it.
I ask for the help of experts.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question