lundi 13 février 2017

how to get access token from OAuth2.0 server for gdrive OAuth2.0

Vote count: 0

I created credential for OAuth2.0. But iam not able to get accesstoken for that.my code is

 public function index()
         {
             return view('modules.school.DriveList.view');
         }

    public function redirect(Request $request)
        {
            $client = new Google_Client();
            $client->setAuthConfig('../client_secrets.json');
            $client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
            $client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] .                                                         '../oauth2callback.php');
           $auth_url = $client->createAuthUrl();
           return redirect('cabinet/drive-redirect');
        }

   public function gdriveredirect(Request $request)
       { 
           $client = new Google_Client();
           $client->authenticate($request->input('code'));
           $access_token = $client->getAccessToken();
           return redirect()->back();
       }

But "$request->input('code')" the quotation code gives undefined code it throws to exception.the When i dd() it the code value is null.

asked 14 secs ago

Let's block ads! (Why?)



how to get access token from OAuth2.0 server for gdrive OAuth2.0

Aucun commentaire:

Enregistrer un commentaire