lundi 20 août 2018

Google oauth getAccessToken() null

I want to add google oauth to my web app, i already follow the google documentation about google oauth with php client library, but i got problem

Here my code

public function googleOauth() {
        $client = new Google_Client();
        $client->setAuthConfig(base_path('google_client.json'));
        //$client->setAccessType("offline");
        $client->setIncludeGrantedScopes(true); 
        $client->addScope(Google_Service_Blogger::BLOGGER);
        $client->setRedirectUri(route('googleOauthCallback'));

        return redirect($client->createAuthUrl());
    }

    public function googleOauthCallback(Request $params) {
       if ($params->code) {
          $client = new Google_Client();
          $client->authenticate($params->code);

          dd($client->getAccessToken());
       }

But the $client->getAccessToken() return null

How to fix it ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire