Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove scope from params for google service #120

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions src/EAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace nodge\eauth;

use Yii;
use yii\base\Object;
use yii\base\BaseObject;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;

Expand All @@ -19,7 +19,7 @@
*
* @package application.extensions.eauth
*/
class EAuth extends Object
class EAuth extends BaseObject
{

/**
Expand Down
4 changes: 2 additions & 2 deletions src/ServiceBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace nodge\eauth;

use Yii;
use yii\base\Object;
use yii\base\BaseObject;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use OAuth\Common\Http\Uri\Uri;
Expand All @@ -21,7 +21,7 @@
*
* @package application.extensions.eauth
*/
abstract class ServiceBase extends Object implements IAuthService
abstract class ServiceBase extends BaseObject implements IAuthService
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/oauth/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function prepareRequest()
}

if (is_array($this->requestBody)) {
$this->requestBody = http_build_query($this->requestBody, null, '&');
$this->requestBody = http_build_query($this->requestBody, "", '&');
}
}

Expand Down
28 changes: 28 additions & 0 deletions src/services/GoogleOAuth2Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
namespace nodge\eauth\services;

use nodge\eauth\oauth2\Service;
use Yii;
use yii\helpers\Url;

/**
* Google provider class.
Expand Down Expand Up @@ -121,6 +123,10 @@ protected function fetchAttributes()
$this->attributes['url'] = $info['link'];
}

if (!empty($info['email'])) {
$this->attributes['email'] = $info['email'];
}

/*if (!empty($info['gender']))
$this->attributes['gender'] = $info['gender'] == 'male' ? 'M' : 'F';

Expand Down Expand Up @@ -166,4 +172,26 @@ protected function fetchResponseError($response)
return null;
}
}

/**
* override getCallbackUrl()
* basically its just ignoring 'scope' param for Google, as they return full urls now
*
* @return string
*/
protected function getCallbackUrl()
{
if (isset($_GET['redirect_uri'])) {
$url = $_GET['redirect_uri'];
}
else {
$route = array();
array_unshift($route, '');
$route['service'] = $_GET['service'];

$url = Url::to($route, true);
}

return $url;
}
}