0

When I try to get access token from Google API but I get null

 $client = new Google_Client(); $client->setApplicationName("name app"); $client->setAccessType('offline'); $client->setClientId('id client'); $client->setClientSecret('secret'); $client->setRedirectUri('redirect url'); $client->addScope("https://www.googleapis.com/auth/calendar.readonly"); //$client->authenticate($_GET['code']); $access_token = $client->getAccessToken(); $tokens_decoded = json_decode($access_token); //$refreshToken = $tokens_decoded->refresh_token; if(!$access_token) { /** * AUCUN TOKEN SAUVE -> IL FAUT REDIRIGER * L'UTILISATEUR SUR L'URL $authUrl */ $authUrl = $client->createAuthUrl(); die(); } 

Please suggest a way to get the same

3
  • You will get access token in redirect URL. Commented Feb 6, 2018 at 9:22
  • Please check this answer which has similar issue stackoverflow.com/a/18264398/3447818 Commented Feb 6, 2018 at 9:24
  • @md84h also error ... getAccesToken is null :( Commented Feb 6, 2018 at 9:30

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.