Я работаю над входом в codeigniter, и результат Google отображается с пустым именем пользователя.
Google_Service_Oauth2_Userinfo Object
([internal_gapi_mappings: protected] => Array ([familyName] => family_name [givenName] => given_name [ VerifiedEmail] => Verified_email)
[email] =>
[familyName] =>
[gender] =>
[givenName] =>
[hd] =>
[id] =>
[link] =>
[locale] =>
[name] =>
[picture] =>
[verifiedEmail] =>
[tableName] => users
)
класс библиотеки
class Google{
public $client;
public $authurl;
public function __construct(){
require APPPATH .'third_party/google-api-client/src/Google/autoload.php';
$this->client = new Google_Client();
$this->client->setApplicationName('Cikko Login with Google');
$this->client->setClientId('69585748028-h8v0dm8j27oi2ipf64du9j1e73ia6n9a.apps.googleusercontent.com');
$this->client->setClientSecret('FWQHrLMwKR0CsFYyR8JQRY8P');
$this->client->setRedirectUri('http://xn--ikko-zoa.com/signin/google_login/');
$this->client->addScope('email');
$this->client->addScope('profile');
$this->client->setApprovalPrompt('force');
$this->client->setAccessType('offline');
$this->authurl = $this->client->createAuthUrl();
}
}
в функции контроллера перенаправления Я написал этот код, вы мне скажите, почему в результате не приходит userinfo?
<code>if(isset($_GET['code'])){
$token = $this->google->client->fetchAccessTokenWithAuthCode($_GET['code']);
if(!isset($token['error']))
{
$this->google->client->setAccessToken($token['access_token']);
$this->session->userdata('access_token' , $token['access_token']);
$google_service = new Google_Service_Oauth2($this->google->client);
$user = $google_service->userinfo->get();
echo '<pre>';
print_r($user);
echo '
';