Skip to content

Instantly share code, notes, and snippets.

@PeeHaa
Created December 19, 2013 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeeHaa/8043525 to your computer and use it in GitHub Desktop.
Save PeeHaa/8043525 to your computer and use it in GitHub Desktop.
Etsy is being a dickhead with its non standard scope implementation. What a dick move
<?php
use OAuth\OAuth1\Service\Etsy;
use OAuth\OAuth1\Signature\SignatureInterface;
use OAuth\Common\Consumer\CredentialsInterface;
use OAuth\Common\Http\Uri\UriInterface;
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\Common\Http\Client\ClientInterface;
class CustomEtsy extends Etsy
{
protected $scopes;
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
TokenStorageInterface $storage,
SignatureInterface $signature,
UriInterface $baseApiUri = null,
array $scopes = array()
) {
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
if (null === $baseApiUri) {
$this->baseApiUri = new Uri('http://openapi.etsy.com/v2/');
}
$this->scopes = $scopes;
}
/**
* {@inheritdoc}
*/
public function getRequestTokenEndpoint()
{
$scopes = '';
if ($this->scopes) {
$scopes = '?' . implode('&', $this->scopes);
}
return new Uri($this->baseApiUri . 'oauth/request_token' . $scopes);
}
}
@algianotti
Copy link

Is this an implementation of the Lusitanian/PHPoAuthLib ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment