Permalink
Browse files

Fixed odd structure on Paypal OAuth2 Provider, CURLOPT_POSTFIELD requ…

…ire string instead of normal array (solved #10)
  • Loading branch information...
1 parent 089e0d7 commit d81a965adcce5828ab109dd71be56124acb5022e @crynobone crynobone committed Aug 9, 2012
Showing with 20 additions and 12 deletions.
  1. +1 −1 libraries/oauth2/provider.php
  2. +10 −9 libraries/oauth2/provider/paypal.php
  3. +9 −2 libraries/oauth2/request.php
@@ -107,7 +107,7 @@ public function __construct(array $options = array())
$this->callback = array_get($options, 'callback');
$this->client_secret = array_get($options, 'secret');
- $this->scope = array_get($options, 'scope');
+ $this->scope = array_get($options, 'scope', $this->scope);
$this->redirect_uri = URL::current();
}
@@ -24,12 +24,12 @@ class 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');
+ protected $scope = 'https://identity.x.com/xidentity/resources/profile/me';
/**
* @var string the method to use when requesting tokens
*/
- protected $method = 'POST';
+ protected $method = 'POST_QUERY';
public function url_authorize()
{
@@ -48,16 +48,17 @@ public function get_user_info(Token_Access $token)
));
$response = json_decode($request->execute());
+
$user = $response->identity;
return array(
- 'uid' => $user['userId'],
- 'nickname' => \Str::slug($user['fullName'], '-'),
- 'name' => $user['fullName'],
- 'first_name' => $user['firstName'],
- 'last_name' => $user['lastName'],
- 'email' => $user['emails'][0],
- 'location' => $user->addresses[0],
+ 'uid' => $user->userId,
+ 'nickname' => \Str::slug($user->fullName, '-'),
+ 'name' => $user->fullName,
+ 'first_name' => $user->firstName,
+ 'last_name' => $user->lastName,
+ 'email' => $user->emails[0],
+ 'location' => isset($user->addresses) ? $user->addresses[0] : '',
'image' => null,
'description' => null,
'urls' => array(
@@ -211,12 +211,19 @@ public function execute(array $options = null)
$options[CURLOPT_SSL_VERIFYPEER] = false;
}
- if ($this->method === 'POST')
+ if (substr($this->method, 0, 4) === 'POST')
{
// Send the request as a POST
$options[CURLOPT_POST] = true;
+ $options[CURLOPT_VERBOSE] = true;
+ $as_string = false;
- if ($post = $this->as_query(null))
+ if ($this->method === 'POST_QUERY')
+ {
+ $as_string = true;
+ }
+
+ if ($post = $this->as_query($as_string))
{
// Attach the post fields to the request
$options[CURLOPT_POSTFIELDS] = $post;

0 comments on commit d81a965

Please sign in to comment.