eee
Showing
2 changed files
with
55 additions
and
1 deletions
| ... | @@ -258,4 +258,58 @@ public function isGoogleFolderCreated($cust_id) | ... | @@ -258,4 +258,58 @@ public function isGoogleFolderCreated($cust_id) |
| 258 | 258 | ||
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | |||
| 262 | public function GoogleTokenCode($code) | ||
| 263 | { | ||
| 264 | |||
| 265 | session_start(); | ||
| 266 | |||
| 267 | |||
| 268 | |||
| 269 | $client = new \Google_Client(); | ||
| 270 | $client->setScopes(array('https://www.googleapis.com/auth/drive.file')); | ||
| 271 | $client->setClientId('206523860143-kgs80emhfm1sof79nggd48gnhbl1j6ei.apps.googleusercontent.com'); | ||
| 272 | $client->setClientSecret('ZzEE02Dqz7AKJLSklmL30LNd'); | ||
| 273 | $client->setRedirectUri('https://pdf-customizer.synapsus.co/auth/google/tokenCallback'); | ||
| 274 | |||
| 275 | $client->setAccessType('offline'); | ||
| 276 | |||
| 277 | $client->setApprovalPrompt('force'); | ||
| 278 | |||
| 279 | |||
| 280 | $client->authenticate($_GET['code']); | ||
| 281 | $_SESSION['token'] = $client->getAccessToken(); | ||
| 282 | |||
| 283 | |||
| 284 | if (isset($_SESSION['token'])) { | ||
| 285 | $client->setAccessToken($_SESSION['token']); | ||
| 286 | } | ||
| 287 | |||
| 288 | if (isset($_REQUEST['logout'])) { | ||
| 289 | unset($_SESSION['token']); | ||
| 290 | $client->revokeToken(); | ||
| 291 | } | ||
| 292 | ?> | ||
| 293 | <!doctype html> | ||
| 294 | <html> | ||
| 295 | <head> | ||
| 296 | <meta charset="utf-8"> | ||
| 297 | </head> | ||
| 298 | <body> | ||
| 299 | <header><h1>Get Token</h1></header> | ||
| 300 | <?php | ||
| 301 | |||
| 302 | $_SESSION['token'] = $client->getAccessToken(); | ||
| 303 | $token = json_decode($_SESSION['token']); | ||
| 304 | echo "Access Token = " . $token->access_token . '<br/>'; | ||
| 305 | echo "Refresh Token = " . $token->refresh_token . '<br/>'; | ||
| 306 | echo "Token type = " . $token->token_type . '<br/>'; | ||
| 307 | echo "Expires in = " . $token->expires_in . '<br/>'; | ||
| 308 | //echo "ID Token = " . $token->id_token . '<br/>'; | ||
| 309 | echo "Created = " . $token->created . '<br/>'; | ||
| 310 | echo "<a class='logout' href='?logout'>Logout</a>"; | ||
| 311 | |||
| 312 | |||
| 313 | } | ||
| 314 | |||
| 261 | } | 315 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -50,4 +50,4 @@ Route::post('fileentry/add',[ 'as' => 'addentry', 'uses' => 'FileEntryController | ... | @@ -50,4 +50,4 @@ Route::post('fileentry/add',[ 'as' => 'addentry', 'uses' => 'FileEntryController |
| 50 | Route::get('api/googlePdfUpload/{folder}/{filename}/{pdfid}/{id}', 'GoogledriveuploadpdfController@google_drive_upload'); | 50 | Route::get('api/googlePdfUpload/{folder}/{filename}/{pdfid}/{id}', 'GoogledriveuploadpdfController@google_drive_upload'); |
| 51 | Route::get('auth/google/callback', 'GoogledriveuploadpdfController@google_drive_upload'); | 51 | Route::get('auth/google/callback', 'GoogledriveuploadpdfController@google_drive_upload'); |
| 52 | Route::get('auth/google/token', 'GoogledriveuploadpdfController@GoogleToken'); | 52 | Route::get('auth/google/token', 'GoogledriveuploadpdfController@GoogleToken'); |
| 53 | Route::get('auth/google/tokenCallback', 'GoogledriveuploadpdfController@GoogleToken'); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 53 | Route::get('auth/google/tokenCallback/{code}', 'GoogledriveuploadpdfController@GoogleTokenCode'); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment