Skip to content

Commit

Permalink
Fix previous merge
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed May 31, 2013
1 parent 2144ff1 commit f608970
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
5 changes: 1 addition & 4 deletions OAuth/ResourceOwner/InstagramResourceOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class InstagramResourceOwner extends GenericOAuth2ResourceOwner
protected $options = array(
'authorization_url' => 'https://api.instagram.com/oauth/authorize',
'access_token_url' => 'https://api.instagram.com/oauth/access_token',
// 'revoke_token_url' => 'https://instagram.com/accounts/manage_access',
// 'infos_url' => 'https://api.instagram.com/v1/users/self',
);

/**
Expand All @@ -39,7 +37,7 @@ class InstagramResourceOwner extends GenericOAuth2ResourceOwner
'realname' => 'user.full_name',
'profilepicture' => 'user.profile_picture',
);

/**
* {@inheritDoc}
*/
Expand All @@ -52,5 +50,4 @@ public function getUserInformation(array $accessToken, array $extraParameters =

return $response;
}

}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ HWIOAuthBundle

The HWIOAuthBundle adds support for authenticating users via OAuth1.0a or OAuth2 in Symfony2.

This bundle contains support for 18 different providers:
This bundle contains support for 19 different providers:
* 37signals,
* Disqus,
* Dropbox,
Expand Down
11 changes: 6 additions & 5 deletions Resources/doc/2x-instagram.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
Step 2x: Setup Instagram
======================
========================
First you will have to register your application on Instagram. Check out the
documentation for more information: instagram.com/developer/authentication/
documentation for more information: http://instagram.com/developer/authentication/

For the API Keys, go to: http://instagram.com/developer/clients/manage/
To add new API Key, you should go to: http://instagram.com/developer/clients/manage/

Your OAuth redirect_uri looks like: https://yourwebsite.com/login/service/instagram (depending on your routing.yml documentation)
Your OAuth redirect_uri looks like: https://yourwebsite.com/login/service/instagram
(depending on your routing.yml documentation)

Next configure a resource owner of type `instagram` with appropriate
`client_id`, `client_secret`.

``` yaml
```yaml
# app/config/config.yml

hwi_oauth:
Expand Down
36 changes: 17 additions & 19 deletions Tests/OAuth/ResourceOwner/InstagramResourceOnwerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

use HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\InstagramResourceOwner;

class InstagramResourceOwnerTest extends GenericOAuth1ResourceOwnerTest
class InstagramResourceOwnerTest extends GenericOAuth2ResourceOwnerTest
{
protected $paths = array(
'identifier' => 'user.id',
'nickname' => 'user.username',
'realname' => 'user.full_name',
'profilepicture' => 'user.profile_picture',
'identifier' => 'user.id',
'nickname' => 'user.username',
'realname' => 'user.full_name',
'profilepicture' => 'user.profile_picture',
);

/**
Expand All @@ -28,12 +28,12 @@ class InstagramResourceOwnerTest extends GenericOAuth1ResourceOwnerTest
public function testGetUserInformation()
{
$accessToken = array(
'oauth_token' => 'token',
'user' => array(
'id' => '1574083',
'full_name' => 'Snoop Dogg',
'username' => 'snoopdogg',
'profilepicture' => 'http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg'
'access_token' => 'token',
'user' => array(
'id' => '1574083',
'username' => 'snoopdogg',
'full_name' => 'Snoop Dogg',
'profile_picture' => 'http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg'
)
);
$userResponse = $this->resourceOwner->getUserInformation($accessToken);
Expand All @@ -42,23 +42,21 @@ public function testGetUserInformation()
$this->assertEquals('snoopdogg', $userResponse->getNickname());
$this->assertEquals('Snoop Dogg', $userResponse->getRealName());
$this->assertEquals('http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg', $userResponse->getProfilePicture());
$this->assertEquals($accessToken['oauth_token'], $userResponse->getAccessToken());
$this->assertEquals($accessToken['access_token'], $userResponse->getAccessToken());
$this->assertNull($userResponse->getRefreshToken());
$this->assertNull($userResponse->getExpiresIn());
}

/**
* Flickr resource owner relies on user data sent with OAuth token, hence no request is made to get user information.
*/
public function testCustomResponseClass()
{
$class = '\HWI\Bundle\OAuthBundle\Tests\Fixtures\CustomUserResponse';
$resourceOwner = $this->createResourceOwner('instagram', array('user_response_class' => $class));

/* @var $userResponse \HWI\Bundle\OAuthBundle\Tests\Fixtures\CustomUserResponse */
$userResponse = $resourceOwner->getUserInformation(array('oauth_token' => 'token'));
$userResponse = $resourceOwner->getUserInformation(array('access_token' => 'token'));

$this->assertInstanceOf($class, $userResponse);
$this->assertEquals('token', $userResponse->getAccessToken());
$this->assertEquals('foo666', $userResponse->getUsername());
$this->assertEquals('foo', $userResponse->getNickname());
}
Expand All @@ -67,12 +65,12 @@ protected function setUpResourceOwner($name, $httpUtils, array $options)
{
$options = array_merge(
array(
'authorization_url' => 'https://api.instagram.com/oauth/authorize',
'access_token_url' => 'https://api.instagram.com/oauth/access_token',
'authorization_url' => 'https://api.instagram.com/oauth/authorize',
'access_token_url' => 'https://api.instagram.com/oauth/access_token',
),
$options
);

return new InstagramResourceOwner($this->buzzClient, $httpUtils, $options, $name, $this->storage);
return new InstagramResourceOwner($this->buzzClient, $httpUtils, $options, $name);
}
}

0 comments on commit f608970

Please sign in to comment.