refresh token with google api client php

后端 未结 1 1983
闹比i
闹比i 2021-02-09 18:23

My pain with google api continues...

I\'m able to use a script to use a refresh token - automatically refresh and keep my access to a calender alive. I can interact with

相关标签:
1条回答
  • 2021-02-09 19:06

    OK - Based on a couple of posts I've fixed the problem of getting the refresh token to get a new access token. I used this code before I started to attempt any access:

    if($client->isAccessTokenExpired()) {
        echo 'Access Token Expired'; // Debug
        $client->refreshToken('X/XXXXXX');
    }
    

    Where the blanked out part in refreshToken is my refresh token. I hard coded the key into the code.

    This is probably not the correct solution as I've seen references to storing the key in a database, so presumably I could store the current access token in a db with the refresh token and pull these form the db as and when required to save hard coding them?

    Hopefully this method I've used will work again after it expires - fingers crossed!

    0 讨论(0)
提交回复
热议问题