rhysnhall / etsy-php-sdk

PHP SDK for Etsy API v3.
MIT License
47 stars 36 forks source link

getReceipts() throwing 'HTTP status code [403] with error "No user was provided as part of the bearer token.".' #13

Closed guerrillacontra closed 2 years ago

guerrillacontra commented 2 years ago

Using an up to date version of your SDK I am wrapping it and ran into that exception:

Etsy\Exception\RequestException 

  Received HTTP status code [403] with error "No user was provided as part of the bearer token.".

  at vendor/rhysnhall/etsy-php-sdk/src/OAuth/Client.php:133
    129▕         $response->error = "{$body->error}";
    130▕         $response->code = $status_code;
    131▕         return $response;
    132▕       }
  ➜ 133▕       throw new RequestException(
    134▕         "Received HTTP status code [$status_code] with error \"{$body->error}\"."
    135▕       );
    136▕     }
    137▕   }

The function I am trying to create looks like this:

    public function getOrders() {
        $etsy = new Etsy($this->api_key, $this->access_token);

        /** @var Shop $shop */
        $shop = $etsy->getShop($this->shop_id);

        //All works I can dd($shop) with results :)

        //This is what is throwing it
        return $shop->getReceipts(['limit'=>10, 'was_paid'=>true]);
    }

Seems to be that 'getReceipts' call.

Thank you for this SDK so far I like where it is heading, just a small snag for now maybe I am doing something wrong?

'getShop()' works correctly and returns valid correct JSON so I think it is just that other call.

rhysnhall commented 2 years ago

Working fine on my end. Before I look further, 403 is an authorization response, so can you confirm that the permissions scope includes transactions_r and that the user you are requesting the receipts for is the one associated with your access token?

guerrillacontra commented 2 years ago

It is probably an access issue, I will look into it when I have the time thank you for the guidance :)

guerrillacontra commented 2 years ago

Update: Turns out I was given an old API key for the V2 etsy API, so generating a new etsy app for it and will try again once approved.