Skip to content

Commit

Permalink
Merge pull request hwi#643 from juliendidier/patch-soundcloud
Browse files Browse the repository at this point in the history
Implements attr_name to catch soundcloud oauth_token var name
  • Loading branch information
stloyd committed Nov 15, 2014
2 parents 54746ec + 56c23d0 commit 989103a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion OAuth/ResourceOwner/GenericOAuth2ResourceOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ public function getUserInformation(array $accessToken, array $extraParameters =
if ($this->options['use_bearer_authorization']) {
$content = $this->httpRequest($this->normalizeUrl($this->options['infos_url']), null, array('Authorization: Bearer '.$accessToken['access_token']));
} else {
$content = $this->doGetUserInformationRequest($this->normalizeUrl($this->options['infos_url'], array('access_token' => $accessToken['access_token'])));
$content = $this->doGetUserInformationRequest($this->normalizeUrl($this->options['infos_url'], array($this->options['attr_name'] => $accessToken['access_token'])));
}

$response = $this->getUserResponse();
$response->setResponse($content->getContent());

$response->setResourceOwner($this);
$response->setOAuthToken(new OAuthToken($accessToken));

Expand Down Expand Up @@ -207,6 +208,7 @@ protected function configureOptions(OptionsResolverInterface $resolver)
parent::configureOptions($resolver);

$resolver->setDefaults(array(
'attr_name' => 'access_token',
'use_commas_in_scope' => false,
'use_bearer_authorization' => true,
));
Expand Down
8 changes: 4 additions & 4 deletions OAuth/ResourceOwner/SoundcloudResourceOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
*/
class SoundcloudResourceOwner extends GenericOAuth2ResourceOwner
{
/**
/**
* {@inheritDoc}
*/
protected $paths = array(
'identifier' => 'id',
'identifier' => 'id',
'nickname' => 'username',
'realname' => 'full_name',
);
Expand All @@ -39,11 +39,11 @@ protected function configureOptions(OptionsResolverInterface $resolver)

$resolver->setDefaults(array(
'access_token_url' => 'https://api.soundcloud.com/oauth2/token',
'attr_name' => 'oauth_token',
'authorization_url' => 'https://soundcloud.com/connect',
'infos_url' => 'https://api.soundcloud.com/me.json',

'use_bearer_authorization' => true,
'scope' => 'non-expiring',
'use_bearer_authorization' => false,
));
}
}
2 changes: 2 additions & 0 deletions Tests/OAuth/ResourceOwner/GenericOAuth2ResourceOwnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class GenericOAuth2ResourceOwnerTest extends \PHPUnit_Framework_TestCase
'infos_url' => 'http://user.info/?test=1',
'authorization_url' => 'http://user.auth/?test=2',
'access_token_url' => 'http://user.access/?test=3',

'attr_name' => 'access_token',
);

protected $userResponse = <<<json
Expand Down

0 comments on commit 989103a

Please sign in to comment.