Not receiving Google OAuth refresh token

前端 未结 14 1415
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 07:38

I want to get the access token from Google. The Google API says that to get the access token, send the code and other parameters to token generating page, and the response

14条回答
  •  礼貌的吻别
    2020-11-22 08:23

    Setting this will cause the refresh token to be sent every time:

    $client->setApprovalPrompt('force');
    

    an example is given below (php):

    $client = new Google_Client();
    $client->setClientId($client_id);
    $client->setClientSecret($client_secret);
    $client->setRedirectUri($redirect_uri);
    $client->addScope("email");
    $client->addScope("profile"); 
    $client->setAccessType('offline');
    $client->setApprovalPrompt('force');
    

提交回复
热议问题