fawkes
Новичок
Для авторизации пользователя на сайте использую гугл. Все работает корректно, за исключением, что при каждом входе он о5 кидает на страницу "Разрешения приложение", где жмакаешь кнопку "Принять". Обычно одного раза достаточно. Но не пойму почему он щас требует это каждый раз.
Раньше просто отсылал гет/пост запросы без google api, проблем не наблюдал.
Scopes
Вопрос, почему? Так надо и в пред. скрипте у меня баг, или чтото тут неправильно?
Раньше просто отсылал гет/пост запросы без google api, проблем не наблюдал.
PHP:
$this->client = new Google_Client();
// ....
$this->client->setApplicationName($cfg['app_name']);
$this->client->setClientId($cfg['client_id']);
$this->client->setClientSecret($cfg['client_secret']);
$this->client->setRedirectUri($cfg['redirect_uri']);
$this->client->setScopes($cfg['scopes']);
$oauth2 = new Google_Oauth2Service($this->client);
// $service = new Google_DriveService($client);
$code = $this->request->query('code');
if (!empty($code)) {
$this->client->authenticate($code);
Session::instance()->set('token', $this->client->getAccessToken());
HTTP::redirect($cfg['redirect_uri']);
}
$token = Session::instance()->get('token');
if (isset($token))
$this->client->setAccessToken($token);
if ($this->client->getAccessToken()) {
$userInfo = $oauth2->userinfo->get();
echo '<pre>';
print_r($userInfo);
echo '</pre>';
Session::instance()->set('token', $this->client->getAccessToken());
HTTP::redirect('/admin');
} else
HTTP::redirect($this->client->createAuthUrl());
Scopes
PHP:
'scopes' => array(
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/drive',
),
Последнее редактирование: