Skip to content

Commit

Permalink
Upgrade to Manager 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DraperStudio committed Mar 30, 2016
1 parent 8f40a3a commit c4e2700
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"email": "[email protected]"
}],
"require": {
"php": ">=5.5.0",
"socialiteproviders/manager": "~1.0"
"php": "^5.6 || ^7.0",
"socialiteproviders/manager": "~2.0"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 7 additions & 4 deletions src/EtsyAbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

namespace SocialiteProviders\Etsy;

use Symfony\Component\HttpFoundation\RedirectResponse;
use Laravel\Socialite\Contracts\Provider as ProviderContract;
use Laravel\Socialite\One\AbstractProvider;
use SocialiteProviders\Manager\OAuth1\AbstractProvider;
use Symfony\Component\HttpFoundation\RedirectResponse;

abstract class EtsyAbstractProvider extends AbstractProvider implements ProviderContract
{
/**
* Unique Provider Identifier.
*/
const IDENTIFIER = 'ETSY';

/**
* Redirect the user to the authentication page for the provider.
*
Expand Down Expand Up @@ -41,13 +46,11 @@ protected function getToken()
$temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
);
} else {

$temp = unserialize($_COOKIE['oauth_temp']);

return $this->server->getTokenCredentials(
$temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
);

}
}

Expand Down
10 changes: 7 additions & 3 deletions src/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

namespace SocialiteProviders\Etsy;

use Laravel\Socialite\One\User;
use SocialiteProviders\Etsy\EtsyAbstractProvider;
use SocialiteProviders\Manager\OAuth1\User;

class Provider extends EtsyAbstractProvider
{
/**
* {@inheritDoc}
* Unique Provider Identifier.
*/
const IDENTIFIER = 'ETSY';

/**
* {@inheritdoc}
*/
public function user()
{
Expand Down
20 changes: 10 additions & 10 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@

namespace SocialiteProviders\Etsy;

use Laravel\Socialite\One\User;
use League\OAuth1\Client\Credentials\TokenCredentials;
use League\OAuth1\Client\Server\Server as BaseServer;
use SocialiteProviders\Manager\OAuth1\Server as BaseServer;
use SocialiteProviders\Manager\OAuth1\User;

class Server extends BaseServer
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function urlTemporaryCredentials()
{
return 'https://openapi.etsy.com/v2/oauth/request_token';
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function urlAuthorization()
{
return 'https://www.etsy.com/oauth/signin';
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function urlTokenCredentials()
{
return 'https://openapi.etsy.com/v2/oauth/access_token';
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function urlUserDetails()
{
return 'https://openapi.etsy.com/v2/users/__SELF__';
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function userDetails($data, TokenCredentials $tokenCredentials)
{
Expand All @@ -56,23 +56,23 @@ public function userDetails($data, TokenCredentials $tokenCredentials)
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function userUid($data, TokenCredentials $tokenCredentials)
{
return $data['results'][0]['user_id'];
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function userEmail($data, TokenCredentials $tokenCredentials)
{
return $data['results'][0]['primary_email'];
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function userScreenName($data, TokenCredentials $tokenCredentials)
{
Expand Down

0 comments on commit c4e2700

Please sign in to comment.