Skip to content

Commit

Permalink
Fixed OAuth issue of not being able to login or create account
Browse files Browse the repository at this point in the history
Fixed OAuth login and creating new user issue #711
  • Loading branch information
eSilverStrike committed Dec 20, 2016
1 parent f8c9f96 commit d86252f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 6 additions & 6 deletions system/classes/oauth/oauth_client.php
Expand Up @@ -2424,7 +2424,7 @@ function to reset the access token state when it is stored in
$this->grant_type = 'authorization_code';
switch($this->server)
{
case 'Facebook':
case 'facebook':
$this->oauth_version = '2.0';
$this->dialog_url = 'https://www.facebook.com/v2.3/dialog/oauth?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}';
$this->reauthenticate_dialog_url = 'https://www.facebook.com/v2.3/dialog/oauth?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}&auth_type=reauthenticate';
Expand All @@ -2437,36 +2437,36 @@ function to reset the access token state when it is stored in
$this->access_token_url = 'https://github.com/login/oauth/access_token';
break;

case 'Google':
case 'google':
$this->oauth_version = '2.0';
$this->dialog_url = 'https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}';
$this->offline_dialog_url = 'https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}&access_type=offline&approval_prompt=force';
$this->access_token_url = 'https://accounts.google.com/o/oauth2/token';
break;

case 'LinkedIn':
case 'linkedin':
$this->oauth_version = '1.0a';
$this->request_token_url = 'https://api.linkedin.com/uas/oauth/requestToken?scope={SCOPE}';
$this->dialog_url = 'https://api.linkedin.com/uas/oauth/authenticate';
$this->access_token_url = 'https://api.linkedin.com/uas/oauth/accessToken';
$this->url_parameters = true;
break;

case 'Microsoft':
case 'microsoft':
$this->oauth_version = '2.0';
$this->dialog_url = 'https://login.live.com/oauth20_authorize.srf?client_id={CLIENT_ID}&scope={SCOPE}&response_type=code&redirect_uri={REDIRECT_URI}&state={STATE}';
$this->access_token_url = 'https://login.live.com/oauth20_token.srf';
break;

case 'Twitter':
case 'twitter':
$this->oauth_version = '1.0a';
$this->request_token_url = 'https://api.twitter.com/oauth/request_token';
$this->dialog_url = 'https://api.twitter.com/oauth/authenticate';
$this->access_token_url = 'https://api.twitter.com/oauth/access_token';
$this->url_parameters = false;
break;

case 'Yahoo':
case 'yahoo':
$this->oauth_version = '1.0a';
$this->request_token_url = 'https://api.login.yahoo.com/oauth/v2/get_request_token';
$this->dialog_url = 'https://api.login.yahoo.com/oauth/v2/request_auth';
Expand Down
8 changes: 5 additions & 3 deletions system/classes/oauthhelper.class.php
Expand Up @@ -69,6 +69,8 @@ public function __construct($service)
{
global $_CONF, $_SYSTEM;

$service = strtolower($service); // always deal in lower case since that is how it is stored in the config

if (strpos($service, 'oauth.') === 0) {
$service = str_replace('oauth.', '', $service);
}
Expand All @@ -94,7 +96,7 @@ public function __construct($service)
}
}

switch (strtolower($this->client->server)) {
switch ($this->client->server) {
case 'facebook' :
$api_url = 'https://graph.facebook.com/me';
$scope = 'email,user_website,user_location,user_about_me,user_photos';
Expand Down Expand Up @@ -348,7 +350,7 @@ protected function _getUpdateUserInfo($info)

protected function _getCreateUserInfo($info)
{
switch (strtolower($this->client->server)) {
switch ($this->client->server) {
case 'facebook' :
$users = array(
'loginname' => (isset($info->first_name) ? $info->first_name : $info->id),
Expand Down Expand Up @@ -448,7 +450,7 @@ protected function _getCreateUserInfo($info)
break;

default:
throw new InvalidArgumentException(__METHOD__ . ': Unknown server "' . strtolower($this->client->server) . '" was given');
throw new InvalidArgumentException(__METHOD__ . ': Unknown server "' . $this->client->server . '" was given');
}

return $users;
Expand Down

0 comments on commit d86252f

Please sign in to comment.