inakiabt / etsy-php

Etsy API wrapper for PHP
74 stars 59 forks source link

Checking Permission Scopes After Authentication #35

Open teraxis opened 6 years ago

teraxis commented 6 years ago

Hi! I decide to check API permission scope. On this page (https://www.etsy.com/developers/documentation/getting_started/oauth#section_checking_permission_scopes_after_authentication) you can get function to do this. I add such function after function setDebug in EtsyClient.php

    public function getScopes()
    {
        $data = $this->oauth->fetch($this->base_url . "/oauth/scopes", null, OAUTH_HTTP_METHOD_GET);
        $json = $this->oauth->getLastResponse();
        echo '<pre>';
        print_r(json_decode($json, true));
    }

And run it by such code

$this->auth = new \Etsy\EtsyClient($auth['consumer_key'], $auth['consumer_secret']);
$this->auth->authorize($auth['access_token'], $auth['access_token_secret']);
$result = $this->auth->getScopes(true);

In result I got answer

Array
(
    [count] => 18
    [results] => Array
        (
            [0] => email_r
            [1] => listings_r
            [2] => listings_w
            [3] => listings_d
            [4] => transactions_r
            [5] => transactions_w
            [6] => billing_r
            [7] => profile_r
            [8] => profile_w
            [9] => address_r
            [10] => address_w
            [11] => favorites_rw
            [12] => shops_rw
            [13] => cart_rw
            [14] => recommend_rw
            [15] => feedback_r
            [16] => treasury_r
            [17] => treasury_w
        )

    [params] => 
    [type] => ArrayString
    [pagination] => Array
        (
        )

)

Maybe it will be useful to others.