Error 37. Not authorized to use this endpoint


#1

Hi,

I’m using Twitter 1.1 API to retweet but constantly get error like this:

POST https://api.twitter.com/1.1/statuses/retweet/358226004998766592.json

HTTP/1.1 403 Forbidden
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-length: 72
content-type: application/json;charset=utf-8
date: Fri, 19 Jul 2013 14:05:44 GMT
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Fri, 19 Jul 2013 14:05:44 GMT
pragma: no-cache
server: tfe
set-cookie: guest_id=v1%3A137424274486055900; Domain=.twitter.com; Path=/; Expires=Sun, 19-Jul-2015 14:05:44 UTC
status: 403 Forbidden
strict-transport-security: max-age=631138519
x-access-level: read-write
x-frame-options: SAMEORIGIN
x-transaction: a7725048c7804127
x-xss-protection: 1; mode=block

Response: {“errors”:[{“code”:37,“message”:“Not authorized to use this endpoint”}]}

Can you please provide some clue on what does it mean and how it should be handled?

Thanks


#2

I assume you’re using OAuth 1.0A and a read-write access token when you’re performing this request?

Is there anything else noteworthy about how you’re formulating the request? Are you sending any cookies along? What kind of programming environment are you in?


#3

Thanks for reply.

I’m in PHP environment, using plain PHP PECL package:

php54-pecl-oauth.x86_64 1.2.2-3.3.amzn1

Token type is read-write, which is stated by response header:

x-access-level: read-write

I’m not sending any cookies.

Here is simplified code or my request:

$oauth = new OAuth($appKey, $appSecret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); $oauth->setToken($token, $secret); $oauth->setTimeout(3000); $headers = ['User-Agent' => ""]; $args = ['trim_user' => true]; $oauth->fetch('https://api.twitter.com/1.1/statuses/retweet/358226004998766592.json', $args, OAUTH_HTTP_METHOD_POST, $headers);

Seems like PECL package supports only OAuth 1.0. This can be a problem.
But why Error 37 occurs for only part of the same-type requests, while others work fine?