本文整理汇总了PHP中Google_Client::setHostedDomain方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_Client::setHostedDomain方法的具体用法?PHP Google_Client::setHostedDomain怎么用?PHP Google_Client::setHostedDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google_Client
的用法示例。
在下文中一共展示了Google_Client::setHostedDomain方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClient
public static function getClient()
{
$creds = GoogleSessionController::getCreds();
$client = new Google_Client();
$env = Config::getEnvironment();
if ($env == 'local' && $creds->oauth_local_path) {
$client->setAuthConfigFile($creds->oauth_local_path);
} else {
if ($creds->oauth_remote_path) {
$client->setAuthConfigFile($creds->oauth_remote_path);
} else {
$client->setApplicationName($creds->app_name);
$client->setClientId($creds->client_id);
$client->setClientSecret($creds->client_secret);
}
}
$client->setRedirectUri(GoogleSessionController::getRedirectURI());
$hd = Config::get('config.google.hd');
if ($hd) {
$client->setHostedDomain($hd);
}
$client->setAccessType('offline');
$client->addScope("https://www.googleapis.com/auth/userinfo.profile");
$client->addScope("https://www.googleapis.com/auth/userinfo.email");
$client->setScopes($creds->scopes);
return $client;
}
示例2: getNewToken
function getNewToken()
{
$client = new Google_Client();
$client->setApplicationName(APPLICATION_NAME);
$client->setScopes(SCOPES);
$client->setAuthConfigFile(CLIENT_SECRET_PATH);
$client->setHostedDomain('email.wosc.edu');
$client->setAccessType('offline');
$client->setApprovalPrompt('force');
$client->setRedirectUri($GMAIL->callback);
$auth_url = $client->createAuthUrl();
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
}
示例3: index
/**
* Default function to load all the google api settings from config file
* @return type
*/
public function index()
{
$client_id = $this->config->item('google_client_id');
$client_secret = $this->config->item('google_client_secret');
$redirect_uri = $this->config->item('google_redirect_uri');
$api_key = $this->config->item('google_api_key');
$hosted_domain = $this->config->item('google_allow_domain');
// Create Client Request to access Google API
$client = new Google_Client();
$client->setApplicationName("PHP Google OAuth Login Example");
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->setDeveloperKey($api_key);
$client->setHostedDomain($hosted_domain);
$client->addScope("https://www.googleapis.com/auth/userinfo.email");
// Send Client Request
$objOAuthService = new Google_Service_Oauth2($client);
// Add Access Token to Session
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
// Set Access Token to make Request
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
}
// Get User Data from Google and store them in $data
if ($client->getAccessToken()) {
$userData = $objOAuthService->userinfo->get();
$data['userData'] = $userData;
$_SESSION['access_token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
$data['authUrl'] = $authUrl;
}
if (isset($authUrl)) {
$this->load->view('login', $data);
} else {
$this->load->model('authentication');
//add the google data in database if not exists
$this->authentication->addGoogleCredentials($userData);
$user_email = $this->session->userdata('user_email');
$this->authentication->checkUserRole($user_email);
$forward_to = $this->session->userdata('user_role');
//redirect to page as per the role
redirect($forward_to . '/landing');
}
}
示例4: constant
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//Google API PHP Library Files
require_once 'google-api-php-client-master/Google/autoload.php';
//Create Client Request to Access Google API
$client = new Google_Client();
$client->setApplicationName("Abre");
$client_id = constant("GOOGLE_CLIENT_ID");
$client->setClientId($client_id);
$client_secret = constant("GOOGLE_CLIENT_SECRET");
$client->setClientSecret($client_secret);
$redirect_uri = constant("GOOGLE_REDIRECT");
$client->setRedirectUri($redirect_uri);
$simple_api_key = constant("GOOGLE_API_KEY");
$client->setDeveloperKey($simple_api_key);
$client->setAccessType("offline");
$scopes = unserialize(constant("GOOGLE_SCOPES"));
$client->setScopes($scopes);
$hd = constant("GOOGLE_HD");
$client->setHostedDomain($hd);
//Send Client Requests
$Service_Oauth2 = new Google_Service_Oauth2($client);
$Service_Plus = new Google_Service_Plus($client);
$Service_Gmail = new Google_Service_Gmail($client);
$Service_Drive = new Google_Service_Drive($client);
$Service_Calendar = new Google_Service_Calendar($client);
$Service_Classroom = new Google_Service_Classroom($client);