<?php
namespace common\modules\eauth\components;

class GoogleOAuth2Service extends \nodge\eauth\services\GoogleOAuth2Service
{
    use ServiceTrait;

    protected $name = 'google';
    
    protected function fetchAttributes()
	{
		$info = $this->makeSignedRequest('https://www.googleapis.com/oauth2/v1/userinfo');

        $profile = [
            'id' => $info['id'],
            'email' => $info['email'],
            'name' => $info['name'],
            'locale' => $info['locale'],
        ];

		$this->attributes['id'] = $info['id'];
		$this->attributes['name'] = $info['name'];
        $this->attributes['url'] = $info['link'];
        $this->attributes['profile'] = $profile;

        $this->setSocialProfile($profile);

        return true;
	}
}
