本文整理汇总了PHP中Google_Client::setClientSecret方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_Client::setClientSecret方法的具体用法?PHP Google_Client::setClientSecret怎么用?PHP Google_Client::setClientSecret使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google_Client
的用法示例。
在下文中一共展示了Google_Client::setClientSecret方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: google
function google()
{
$client = new Google_Client();
$client->setApplicationName("snmmaurya");
$client->setClientId(CLIENT_ID);
$client->setClientSecret(CLIENT_SECRET);
$client->setRedirectUri(REDIRECT_URI);
$client->setApprovalPrompt(APPROVAL_PROMPT);
$client->setAccessType(ACCESS_TYPE);
$oauth2 = new Google_Oauth2Service($client);
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
if (isset($_REQUEST['error'])) {
echo '<script type="text/javascript">window.close();</script>';
exit;
}
if ($client->getAccessToken()) {
$user = $oauth2->userinfo->get();
$_SESSION['User'] = $user;
$_SESSION['token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
header('Location: ' . $authUrl);
}
}
示例2: __construct
public function __construct()
{
include_once AB_PATH . '/lib/google_api_v3/autoload.php';
$this->client = new Google_Client();
$this->client->setClientId(get_option('ab_settings_google_client_id'));
$this->client->setClientSecret(get_option('ab_settings_google_client_secret'));
}
示例3: __construct
public function __construct($oauthClientId, $oauthClientSecret, $oAuthConfig = array())
{
$this->client = new \Google_Client();
$this->client->setClassConfig('Google_Auth_OAuth2', $oAuthConfig);
$this->client->setClientId($oauthClientId);
$this->client->setClientSecret($oauthClientSecret);
}
示例4: __construct
/**
* Google constructor.
*/
public function __construct()
{
$this->_googleClient = new \Google_Client();
$this->_googleClient->setClientId(KACANA_SOCIAL_GOOGLE_KEY);
$this->_googleClient->setClientSecret(KACANA_SOCIAL_GOOGLE_SECRET);
$this->_googleClient->setApplicationName(KACANA_SOCIAL_GOOGLE_APP_NAME);
$this->_googleClient->setRedirectUri('postmessage');
}
示例5: __construct
/**
* @param \Google_Client $client
*/
public function __construct(\Google_Client $client)
{
$this->client = $client;
$this->client->setClientId(\Config::get('google.client_id'));
$this->client->setClientSecret(\Config::get('google.client_secret'));
$this->client->setDeveloperKey(\Config::get('google.api_key'));
$this->client->setRedirectUri(\Config::get('app.url') . "/loginCallback");
$this->client->setScopes(['https://www.googleapis.com/auth/youtube']);
$this->client->setAccessType('offline');
}
示例6: __construct
/**
* Google
* @param $params array - data from config.neon
* @param $cookieName String cookie name
* @param Nette\Http\Response $httpResponse
* @param Nette\Http\Request $httpRequest
*/
public function __construct($params, $cookieName, Nette\Http\Response $httpResponse, Nette\Http\Request $httpRequest)
{
$this->params = $params;
$this->cookieName = $cookieName;
$this->httpResponse = $httpResponse;
$this->httpRequest = $httpRequest;
$this->client = new \Google_Client();
$this->client->setClientId($this->params["clientId"]);
$this->client->setClientSecret($this->params["clientSecret"]);
$this->client->setRedirectUri($this->params["callbackURL"]);
}
示例7: __construct
/**
* Constructor.
*
* @param int $repositoryid repository instance id.
* @param int|stdClass $context a context id or context object.
* @param array $options repository options.
* @param int $readonly indicate this repo is readonly or not.
* @return void
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array(), $readonly = 0)
{
parent::__construct($repositoryid, $context, $options, $readonly = 0);
$callbackurl = new moodle_url(self::CALLBACKURL);
$this->client = get_google_client();
$this->client->setClientId(get_config('googledocs', 'clientid'));
$this->client->setClientSecret(get_config('googledocs', 'secret'));
$this->client->setScopes(array(Google_Service_Drive::DRIVE_READONLY));
$this->client->setRedirectUri($callbackurl->out(false));
$this->service = new Google_Service_Drive($this->client);
$this->check_login();
}
示例8: __construct
/**
* Constructor.
*
* @param int $repositoryid repository instance id.
* @param int|stdClass $context a context id or context object.
* @param array $options repository options.
* @param int $readonly indicate this repo is readonly or not.
* @return void
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array(), $readonly = 0)
{
parent::__construct($repositoryid, $context, $options, $readonly = 0);
$callbackurl = new moodle_url(self::CALLBACKURL);
$this->client = new Google_Client();
$this->client->setClientId(get_config('googledocs', 'clientid'));
$this->client->setClientSecret(get_config('googledocs', 'secret'));
$this->client->setScopes(array('https://www.googleapis.com/auth/drive.readonly'));
$this->client->setRedirectUri($callbackurl->out(false));
$this->service = new Google_DriveService($this->client);
$this->check_login();
}
示例9: __construct
/**
* Google
* @param $params array - data from config.neon
* @param $cookieName String cookie name
* @param Nette\Http\Response $httpResponse
* @param Nette\Http\Request $httpRequest
*/
public function __construct($params, $cookieName, Nette\Http\Response $httpResponse, Nette\Http\Request $httpRequest)
{
$this->params = $params;
$this->cookieName = $cookieName;
$this->httpResponse = $httpResponse;
$this->httpRequest = $httpRequest;
$config = new \Google_Config();
$config->setClassConfig('Google_Cache_File', array('directory' => '/temp/cache'));
$this->client = new \Google_Client($config);
$this->client->setClientId($this->params["clientId"]);
$this->client->setClientSecret($this->params["clientSecret"]);
$this->client->setRedirectUri($this->params["callbackURL"]);
}
示例10: initializeClient
public function initializeClient()
{
$this->client = new Client();
$this->client->setAccessType('offline');
$this->client->setApplicationName('playlister');
$this->client->setClientId($this->config->get('services.youtube.client_id'));
$this->client->setClientSecret($this->config->get('services.youtube.client_secret'));
$this->client->setRedirectUri($this->config->get('services.youtube.redirect'));
$this->client->setDeveloperKey($this->config->get('services.youtube.api_key'));
$this->client->addScope('https://www.googleapis.com/auth/youtube.readonly');
if ($this->auth->check() && $this->request->session()->has('user.token')) {
$this->setToken($this->request->session()->get('user.token'));
}
}
示例11: googleCallbackAction
public function googleCallbackAction()
{
$response = array("status" => 0, "message" => "Thao tác không thành công");
$code = $this->request->getPost("code", null, false);
if ($code) {
$google = new \Google_Client();
$google->setApplicationName($this->config["GOOGLE_NAME"]);
$google->setClientId($this->config["GOOGLE_ID"]);
$google->setClientSecret($this->config["GOOGLE_SECRET"]);
$google->setRedirectUri('postmessage');
$scopes = array("https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email");
$google->setScopes($scopes);
$google->authenticate($code);
$request = new \Google_Http_Request("https://www.googleapis.com/oauth2/v2/userinfo?alt=json");
$userinfo = $google->getAuth()->authenticatedRequest($request);
$response = $userinfo->getResponseBody();
$userinfo = json_decode($response, true);
$id = $userinfo["id"];
$username = explode("@", $userinfo["email"]);
$username = $username[0] . "_gg_" . $id;
$data_user = array("email" => $userinfo["email"], "nickname" => $userinfo["name"], "username" => $username, "id" => $id);
$response = $this->doSocialLogin($data_user);
}
echo json_encode($response);
exit;
}
示例12: call_back
public function call_back()
{
$config = new Controllers_Api_Google_Config_App();
$client = new Google_Client();
$client->setClientId($config->config['client_id']);
$client->setClientSecret($config->config['client_secret']);
$client->setRedirectUri($config->config['redirect_uri']);
$client->addScope("email");
$client->addScope("profile");
$service = new Google_Service_Oauth2($client);
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
header('Location: ' . filter_var($config->config['redirect_uri'], FILTER_SANITIZE_URL));
exit;
}
/************************************************
If we have an access token, we can make
requests, else we generate an authentication URL.
************************************************/
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
} else {
$authUrl = $client->createAuthUrl();
}
if (isset($authUrl)) {
//show login url
echo json_encode(array('status' => false, 'data' => $authUrl));
} else {
$user = $service->userinfo->get();
//get user info
echo json_encode(array('status' => true, 'data' => $user));
}
}
示例13: revokeAccessToken
public static function revokeAccessToken()
{
$xmpData = erLhcoreClassModelChatConfig::fetch('xmp_data');
$data = (array) $xmpData->data;
try {
if (isset($data['gtalk_client_token']) && $data['gtalk_client_token'] != '') {
require_once 'lib/core/lhxmp/google/Google_Client.php';
$client = new Google_Client();
$client->setApplicationName('Live Helper Chat');
$client->setScopes(array("https://www.googleapis.com/auth/googletalk", "https://www.googleapis.com/auth/userinfo.email"));
$client->setClientId($data['gtalk_client_id']);
$client->setClientSecret($data['gtalk_client_secret']);
$client->setAccessType('offline');
$client->setApprovalPrompt('force');
$token = $data['gtalk_client_token'];
$client->setAccessToken($data['gtalk_client_token']);
// Refresh token if it's
if ($client->isAccessTokenExpired()) {
$tokenData = json_decode($token);
$client->refreshToken($tokenData->refresh_token);
$accessToken = $client->getAccessToken();
}
if ($accessToken = $client->getAccessToken()) {
$client->revokeToken();
}
unset($data['gtalk_client_token']);
$xmpData->value = serialize($data);
$xmpData->saveThis();
}
return true;
} catch (Exception $e) {
throw $e;
}
}
示例14: __construct
public function __construct()
{
$google = new \Google_Client();
$google->setClientId(Setting::get('google.clientId'));
$google->setClientSecret(Setting::get('google.clientSecret'));
$this->google = $google;
}
示例15: flow
/**
* Google login method
* --
*/
public function flow()
{
$client = new Google_Client();
$client->setClientId($this->client_id);
$client->setClientSecret($this->client_secret);
$client->setRedirectUri($this->redirect_url);
$client->addScope("email");
$client->addScope("profile");
$this->context = Context::getContext();
$this->client = $client;
$this->service = new Google_Service_Oauth2($this->client);
if (Tools::getValue('code')) {
$this->client->authenticate(Tools::getValue('code'));
$this->context->cookie->__set('googleconnect_access_token', serialize($this->client->getAccessToken()));
Tools::redirect(filter_var($this->redirect_url, FILTER_SANITIZE_URL));
} else {
if ($this->context->cookie->__isset('googleconnect_access_token')) {
$a_token = unserialize($this->context->cookie->__get('googleconnect_access_token'));
$this->client->setAccessToken($a_token);
if (!$this->client->isAccessTokenExpired()) {
$this->context->cookie->__unset('googleconnect_access_token');
$this->loginToStore();
} else {
$this->setAuthUrl();
}
} else {
$this->setAuthUrl();
}
}
}