Refresh a access token with google analytics api [

2019-03-31 04:43发布

I try to refresh an access token with the google analytics API (php) but I've always the invalid_grant error ... that's my process:

1. I save a first acces token in my database with a offline request, the response is:

{"access_token":"ya29.AHES6ZSPMUyKfx06Bw89LnlfRa5mEmwdthyCUj6D7bRmDcQ","token_type":"Bearer","expires_in":3600,"refresh_token":"1\/1XLO8PLs2Pb0NPs-T-lt07jWW_STBWYG3IGRB08ZbkA","created":1338810086}

2. I check the token info, if "expires_in" < 0 i try to refresh my token:

if ($infoAt['expires_in'] <= 0) {
 $row = $database->loadObject("SELECT refresh from token WHERE id=1");
 $client->refreshToken($row['refresh']);
}

and I've a invalid_grant error ...

any help ? Thanks a lot and sorry for my english ...

0条回答
登录 后发表回答