芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/cloud.pulsehost.co.uk/modules/GoogleAuthWebclient/Classes/Connector.php
offline = true; $oClient->debug = self::$Debug; $oClient->debug_http = self::$Debug; $oClient->server = 'Google'; $oClient->redirect_uri = $this->GetRedirectUrl(); $oClient->client_id = $sId; $oClient->client_secret = $sSecret; $oClient->scope = $sScopes; return $oClient; } public function Init($Id, $sSecret, $aScopes = []) { $mResult = false; $oClient = $this->CreateClient($Id, $sSecret, $aScopes[1]); if ($oClient) { $oUser = null; if (($bSuccess = $oClient->Initialize())) { if (($bSuccess = $oClient->Process())) { if (strlen($oClient->authorization_error)) { $oClient->error = $oClient->authorization_error; $bSuccess = false; } elseif (strlen($oClient->access_token)) { $bSuccess = $oClient->CallAPI( 'https://www.googleapis.com/oauth2/v1/userinfo', 'GET', array(), array( 'FailOnAccessError' => true ), $oUser ); } } $bSuccess = $oClient->Finalize($bSuccess); } if ($oClient->exit) { exit; } if ($bSuccess && $oUser) { $iExpiresIn = 3600; $dAccessTokenExpiry = new \DateTime($oClient->access_token_expiry); $mResult = array( 'type' => $this->Name, 'id' => $oUser->id, 'name' => $oUser->name, 'email' => isset($oUser->email) ? $oUser->email : '', 'access_token' => \json_encode(array( 'access_token' => $oClient->access_token, 'created' => ($dAccessTokenExpiry->getTimestamp() - $iExpiresIn), 'expires_in' => $iExpiresIn )), 'refresh_token' => $oClient->refresh_token, 'scopes' => \explode('|', $aScopes[0]) ); } else { $mResult = [ 'type' => $this->Name, 'error' => $oClient->error ]; $oClient->ResetAccessToken(); } } return $mResult; } }