Removed older providers as they just need rewriting from scratch
parent
8e641737af
commit
3b050dafb2
|
@ -1,40 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace OAuth2\Client\Provider;
|
|
||||||
|
|
||||||
class foursquare extends IdentityProvider
|
|
||||||
{
|
|
||||||
public function urlAuthorize()
|
|
||||||
{
|
|
||||||
return 'https://foursquare.com/oauth2/authenticate';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function urlAccessToken()
|
|
||||||
{
|
|
||||||
return 'https://foursquare.com/oauth2/access_token';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function urlUserDetails(\OAuth2\Client\Token\AccessToken $token)
|
|
||||||
{
|
|
||||||
return 'https://api.foursquare.com/v2/users/selfoauth_token='.$token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function userDetails($response, \OAuth2\Client\Token\AccessToken $token)
|
|
||||||
{
|
|
||||||
die(print_r($response));
|
|
||||||
|
|
||||||
/*$user = new User;
|
|
||||||
$user->uid = $response->response->user->id;
|
|
||||||
$user->name = $response->response->user->name;
|
|
||||||
$user->lastName = $response->response->user->last_name;
|
|
||||||
$user->email = isset($response->response->user->email) ? $response->response->user->email : null;
|
|
||||||
$user->location = isset($response->response->user->hometown->name) ? $response->response->user->hometown->name : null;
|
|
||||||
$user->description = isset($response->response->user->bio) ? $response->response->user->bio : null;
|
|
||||||
$user->imageUrl = $imageHeaders['Location'];
|
|
||||||
$user->urls = array(
|
|
||||||
'Facebook' => $response->response->user->link,
|
|
||||||
);
|
|
||||||
|
|
||||||
return $user;*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
/**
|
|
||||||
* Instagram OAuth2 Provider
|
|
||||||
*
|
|
||||||
* @package CodeIgniter/OAuth2
|
|
||||||
* @category Provider
|
|
||||||
* @author Phil Sturgeon
|
|
||||||
* @copyright (c) 2012 HappyNinjas Ltd
|
|
||||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OAuth2_Provider_Instagram extends OAuth2_Provider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string scope separator, most use "," but some like Google are spaces
|
|
||||||
*/
|
|
||||||
public $scope_seperator = '+';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string the method to use when requesting tokens
|
|
||||||
*/
|
|
||||||
public $method = 'POST';
|
|
||||||
|
|
||||||
public function url_authorize()
|
|
||||||
{
|
|
||||||
return 'https://api.instagram.com/oauth/authorize';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function url_access_token()
|
|
||||||
{
|
|
||||||
return 'https://api.instagram.com/oauth/access_token';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_user_info(OAuth2_Token_Access $token)
|
|
||||||
{
|
|
||||||
$user = $token->user;
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'uid' => $user->id,
|
|
||||||
'nickname' => $user->username,
|
|
||||||
'name' => $user->full_name,
|
|
||||||
'image' => $user->profile_picture,
|
|
||||||
'urls' => array(
|
|
||||||
'website' => $user->website,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
/**
|
|
||||||
* Mailchimp OAuth2 Provider
|
|
||||||
*
|
|
||||||
* @package CodeIgniter/OAuth2
|
|
||||||
* @category Provider
|
|
||||||
* @author Phil Sturgeon
|
|
||||||
* @copyright (c) 2012 HappyNinjas Ltd
|
|
||||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OAuth2_Provider_Mailchimp extends OAuth2_Provider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string the method to use when requesting tokens
|
|
||||||
*/
|
|
||||||
protected $method = 'POST';
|
|
||||||
|
|
||||||
public function url_authorize()
|
|
||||||
{
|
|
||||||
return 'https://login.mailchimp.com/oauth2/authorize';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function url_access_token()
|
|
||||||
{
|
|
||||||
return 'https://login.mailchimp.com/oauth2/token';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_user_info(OAuth2_Token_Access $token)
|
|
||||||
{
|
|
||||||
// Create a response from the request
|
|
||||||
return array(
|
|
||||||
'uid' => $token->access_token,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
/**
|
|
||||||
* Mailru OAuth2 Provider
|
|
||||||
*
|
|
||||||
* @package CodeIgniter/OAuth2
|
|
||||||
* @category Provider
|
|
||||||
* @author Lavr Lyndin
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OAuth2_Provider_Mailru extends OAuth2_Provider
|
|
||||||
{
|
|
||||||
public $method = 'POST';
|
|
||||||
|
|
||||||
public function url_authorize()
|
|
||||||
{
|
|
||||||
return 'https://connect.mail.ru/oauth/authorize';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function url_access_token()
|
|
||||||
{
|
|
||||||
return 'https://connect.mail.ru/oauth/token';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function sign_server_server(array $request_params, $secret_key)
|
|
||||||
{
|
|
||||||
ksort($request_params);
|
|
||||||
$params = '';
|
|
||||||
foreach ($request_params as $key => $value) {
|
|
||||||
$params .= "$key=$value";
|
|
||||||
}
|
|
||||||
return md5($params . $secret_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_user_info(OAuth2_Token_Access $token)
|
|
||||||
{
|
|
||||||
$request_params = array(
|
|
||||||
'app_id' => $this->client_id,
|
|
||||||
'method' => 'users.getInfo',
|
|
||||||
'uids' => $token->uid,
|
|
||||||
'access_token' => $token->access_token,
|
|
||||||
'secure' => 1
|
|
||||||
);
|
|
||||||
|
|
||||||
$sig = $this->sign_server_server($request_params,$this->client_secret);
|
|
||||||
$url = 'http://www.appsmail.ru/platform/api?'.http_build_query($request_params).'&sig='.$sig;
|
|
||||||
|
|
||||||
$user = json_decode(file_get_contents($url));
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'uid' => $user[0]->uid,
|
|
||||||
'nickname' => $user[0]->nick,
|
|
||||||
'name' => $user[0]->first_name.' '.$user[0]->last_name,
|
|
||||||
'first_name' => $user[0]->first_name,
|
|
||||||
'last_name' => $user[0]->last_name,
|
|
||||||
'email' => isset($user[0]->email) ? $user[0]->email : null,
|
|
||||||
'image' => isset($user[0]->pic_big) ? $user[0]->pic_big : null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function authorize($options = array())
|
|
||||||
{
|
|
||||||
$state = md5(uniqid(rand(), TRUE));
|
|
||||||
get_instance()->session->set_userdata('state', $state);
|
|
||||||
|
|
||||||
$params = array(
|
|
||||||
'client_id' => $this->client_id,
|
|
||||||
'redirect_uri' => isset($options['redirect_uri']) ? $options['redirect_uri'] : $this->redirect_uri,
|
|
||||||
'response_type' => 'code',
|
|
||||||
);
|
|
||||||
|
|
||||||
redirect($this->url_authorize().'?'.http_build_query($params));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
/**
|
|
||||||
* PayPal OAuth2 Provider
|
|
||||||
*
|
|
||||||
* @package CodeIgniter/OAuth2
|
|
||||||
* @category Provider
|
|
||||||
* @author Phil Sturgeon
|
|
||||||
* @copyright (c) 2012 HappyNinjas Ltd
|
|
||||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OAuth2_Provider_Paypal extends OAuth2_Provider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string default scope (useful if a scope is required for user info)
|
|
||||||
*/
|
|
||||||
protected $scope = array('https://identity.x.com/xidentity/resources/profile/me');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string the method to use when requesting tokens
|
|
||||||
*/
|
|
||||||
protected $method = 'POST';
|
|
||||||
|
|
||||||
public function url_authorize()
|
|
||||||
{
|
|
||||||
return 'https://identity.x.com/xidentity/resources/authorize';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function url_access_token()
|
|
||||||
{
|
|
||||||
return 'https://identity.x.com/xidentity/oauthtokenservice';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_user_info(OAuth2_Token_Access $token)
|
|
||||||
{
|
|
||||||
$url = 'https://identity.x.com/xidentity/resources/profile/me?' . http_build_query(array(
|
|
||||||
'oauth_token' => $token->access_token
|
|
||||||
));
|
|
||||||
|
|
||||||
$user = json_decode(file_get_contents($url));
|
|
||||||
$user = $user->identity;
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'uid' => $user['userId'],
|
|
||||||
'nickname' => url_title($user['fullName'], '_', true),
|
|
||||||
'name' => $user['fullName'],
|
|
||||||
'first_name' => $user['firstName'],
|
|
||||||
'last_name' => $user['lastName'],
|
|
||||||
'email' => $user['emails'][0],
|
|
||||||
'location' => $user->addresses[0],
|
|
||||||
'image' => null,
|
|
||||||
'description' => null,
|
|
||||||
'urls' => array(
|
|
||||||
'PayPal' => null
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
/**
|
|
||||||
* Soundcloud OAuth2 Provider
|
|
||||||
*
|
|
||||||
* @package CodeIgniter/OAuth2
|
|
||||||
* @category Provider
|
|
||||||
* @author Phil Sturgeon
|
|
||||||
* @copyright (c) 2012 HappyNinjas Ltd
|
|
||||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OAuth2_Provider_Soundcloud extends OAuth2_Provider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string the method to use when requesting tokens
|
|
||||||
*/
|
|
||||||
protected $method = 'POST';
|
|
||||||
|
|
||||||
public function url_authorize()
|
|
||||||
{
|
|
||||||
return 'https://soundcloud.com/connect';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function url_access_token()
|
|
||||||
{
|
|
||||||
return 'https://api.soundcloud.com/oauth2/token';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_user_info(OAuth2_Token_Access $token)
|
|
||||||
{
|
|
||||||
$url = 'https://api.soundcloud.com/me.json?'.http_build_query(array(
|
|
||||||
'oauth_token' => $token->access_token,
|
|
||||||
));
|
|
||||||
|
|
||||||
$user = json_decode(file_get_contents($url));
|
|
||||||
|
|
||||||
// Create a response from the request
|
|
||||||
return array(
|
|
||||||
'uid' => $user->id,
|
|
||||||
'nickname' => $user->username,
|
|
||||||
'name' => $user->full_name,
|
|
||||||
'location' => $user->country.' ,'.$user->country,
|
|
||||||
'description' => $user->description,
|
|
||||||
'image' => $user->avatar_url,
|
|
||||||
'urls' => array(
|
|
||||||
'MySpace' => $user->myspace_name,
|
|
||||||
'Website' => $user->website,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
/**
|
|
||||||
* Vkontakte OAuth2 Provider
|
|
||||||
*
|
|
||||||
* @package CodeIgniter/OAuth2
|
|
||||||
* @category Provider
|
|
||||||
* @author Lavr Lyndin
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OAuth2_Provider_Vkontakte extends OAuth2_Provider
|
|
||||||
{
|
|
||||||
protected $method = 'POST';
|
|
||||||
public $uid_key = 'user_id';
|
|
||||||
|
|
||||||
public function url_authorize()
|
|
||||||
{
|
|
||||||
return 'http://oauth.vk.com/authorize';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function url_access_token()
|
|
||||||
{
|
|
||||||
return 'https://oauth.vk.com/access_token';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_user_info(OAuth2_Token_Access $token)
|
|
||||||
{
|
|
||||||
$scope = array('nickname', 'screen_name','photo_big');
|
|
||||||
$url = 'https://api.vk.com/method/users.get?'.http_build_query(array(
|
|
||||||
'uids' => $token->uid,
|
|
||||||
'fields' => implode(",",$scope),
|
|
||||||
'access_token' => $token->access_token,
|
|
||||||
));
|
|
||||||
|
|
||||||
$user = json_decode(file_get_contents($url))->response;
|
|
||||||
|
|
||||||
if(sizeof($user)==0)
|
|
||||||
return null;
|
|
||||||
else
|
|
||||||
$user = $user[0];
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'uid' => $user->uid,
|
|
||||||
'nickname' => isset($user->nickname) ? $user->nickname : null,
|
|
||||||
'name' => isset($user->name) ? $user->name : null,
|
|
||||||
'first_name' => isset($user->first_name) ? $user->first_name : null,
|
|
||||||
'last_name' => isset($user->last_name) ? $user->last_name : null,
|
|
||||||
'email' => null,
|
|
||||||
'location' => null,
|
|
||||||
'description' => null,
|
|
||||||
'image' => isset($user->photo_big) ? $user->photo_big : null,
|
|
||||||
'urls' => array(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
/**
|
|
||||||
* Windows Live OAuth2 Provider
|
|
||||||
*
|
|
||||||
* @package CodeIgniter/OAuth2
|
|
||||||
* @category Provider
|
|
||||||
* @author Phil Sturgeon
|
|
||||||
* @copyright (c) 2012 HappyNinjas Ltd
|
|
||||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OAuth2_Provider_Windowslive extends OAuth2_Provider
|
|
||||||
{
|
|
||||||
protected $scope = array('wl.basic', 'wl.emails');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string the method to use when requesting tokens
|
|
||||||
*/
|
|
||||||
protected $method = 'POST';
|
|
||||||
|
|
||||||
// authorise url
|
|
||||||
public function url_authorize()
|
|
||||||
{
|
|
||||||
return 'https://oauth.live.com/authorize';
|
|
||||||
}
|
|
||||||
|
|
||||||
// access token url
|
|
||||||
public function url_access_token()
|
|
||||||
{
|
|
||||||
return 'https://oauth.live.com/token';
|
|
||||||
}
|
|
||||||
|
|
||||||
// get basic user information
|
|
||||||
/********************************
|
|
||||||
** this can be extended through the
|
|
||||||
** use of scopes, check out the document at
|
|
||||||
** http://msdn.microsoft.com/en-gb/library/hh243648.aspx#user
|
|
||||||
*********************************/
|
|
||||||
public function get_user_info(OAuth2_Token_Access $token)
|
|
||||||
{
|
|
||||||
// define the get user information token
|
|
||||||
$url = 'https://apis.live.net/v5.0/me?'.http_build_query(array(
|
|
||||||
'access_token' => $token->access_token,
|
|
||||||
));
|
|
||||||
|
|
||||||
// perform network request
|
|
||||||
$user = json_decode(file_get_contents($url));
|
|
||||||
|
|
||||||
// create a response from the request and return it
|
|
||||||
return array(
|
|
||||||
'uid' => $user->id,
|
|
||||||
'name' => $user->name,
|
|
||||||
'nickname' => url_title($user->name, '_', true),
|
|
||||||
// 'location' => $user[''], # scope wl.postal_addresses is required
|
|
||||||
# but won't be implemented by default
|
|
||||||
'locale' => $user->locale,
|
|
||||||
'urls' => array('Windows Live' => $user->link),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,115 +0,0 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
/**
|
|
||||||
* Yandex OAuth2 Provider
|
|
||||||
*
|
|
||||||
* @package CodeIgniter/OAuth2
|
|
||||||
* @category Provider
|
|
||||||
* @author Lavr Lyndin
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OAuth2_Provider_Yandex extends OAuth2_Provider
|
|
||||||
{
|
|
||||||
public $method = 'POST';
|
|
||||||
|
|
||||||
public function url_authorize()
|
|
||||||
{
|
|
||||||
return 'https://oauth.yandex.ru/authorize';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function url_access_token()
|
|
||||||
{
|
|
||||||
return 'https://oauth.yandex.ru/token';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_user_info(OAuth2_Token_Access $token)
|
|
||||||
{
|
|
||||||
$opts = array(
|
|
||||||
'http' => array(
|
|
||||||
'method' => 'GET',
|
|
||||||
'header' => 'Authorization: OAuth '.$token->access_token
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$_default_opts = stream_context_get_params(stream_context_get_default());
|
|
||||||
|
|
||||||
$opts = array_merge_recursive($_default_opts['options'], $opts);
|
|
||||||
$context = stream_context_create($opts);
|
|
||||||
$url = 'http://api-yaru.yandex.ru/me/?format=json';
|
|
||||||
|
|
||||||
$user = json_decode(file_get_contents($url,false,$context));
|
|
||||||
|
|
||||||
preg_match("/\d+$/",$user->id,$uid);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'uid' => $uid[0],
|
|
||||||
'nickname' => isset($user->name) ? $user->name : null,
|
|
||||||
'name' => isset($user->name) ? $user->name : null,
|
|
||||||
'first_name' => isset($user->first_name) ? $user->first_name : null,
|
|
||||||
'last_name' => isset($user->last_name) ? $user->last_name : null,
|
|
||||||
'email' => isset($user->email) ? $user->email : null,
|
|
||||||
'location' => isset($user->hometown->name) ? $user->hometown->name : null,
|
|
||||||
'description' => isset($user->bio) ? $user->bio : null,
|
|
||||||
'image' => $user->links->userpic,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function access($code, $options = array())
|
|
||||||
{
|
|
||||||
$params = array(
|
|
||||||
'client_id' => $this->client_id,
|
|
||||||
'client_secret' => $this->client_secret,
|
|
||||||
'grant_type' => isset($options['grant_type']) ? $options['grant_type'] : 'authorization_code',
|
|
||||||
);
|
|
||||||
|
|
||||||
switch ($params['grant_type'])
|
|
||||||
{
|
|
||||||
case 'authorization_code':
|
|
||||||
$params['code'] = $code;
|
|
||||||
$params['redirect_uri'] = isset($options['redirect_uri']) ? $options['redirect_uri'] : $this->redirect_uri;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'refresh_token':
|
|
||||||
$params['refresh_token'] = $code;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = null;
|
|
||||||
$url = $this->url_access_token();
|
|
||||||
|
|
||||||
$curl = curl_init($url);
|
|
||||||
|
|
||||||
$headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8;';
|
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
|
|
||||||
// curl_setopt($curl, CURLOPT_USERAGENT, 'yamolib-php');
|
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
|
|
||||||
curl_setopt($curl, CURLOPT_TIMEOUT, 80);
|
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
|
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
|
|
||||||
// curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/../data/ca-certificate.crt');
|
|
||||||
|
|
||||||
$response = curl_exec($curl);
|
|
||||||
curl_close($curl);
|
|
||||||
|
|
||||||
$return = json_decode($response, true);
|
|
||||||
|
|
||||||
if ( ! empty($return['error']))
|
|
||||||
{
|
|
||||||
throw new OAuth2_Exception($return);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($params['grant_type'])
|
|
||||||
{
|
|
||||||
case 'authorization_code':
|
|
||||||
return OAuth2_Token::factory('access', $return);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'refresh_token':
|
|
||||||
return OAuth2_Token::factory('refresh', $return);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue