Unable to access Twitter account activity premium APIs

oauth
api

#1

Hi,

Good day,

I am trying to add webhook in twitter account activity premium APIs.

I am following this documentation - https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/guides/getting-started-with-webhooks

So as of now -

  1. I have created twitter app, generated all 4 keys.
  2. I have twitter developer account.
  3. Then set up dev envi. as below,

  1. I have also created webhook consumer app with both GET(for CRC check) & POST(for listening event from twitter).
  2. But in the final step that is registering webhook url to the Account Activity API, in POST call I am getting below error -
    {
    “errors”: [
    {
    “code”: 32,
    “message”: “Could not authenticate you.”
    }
    ]
    }

I tried different things like regenerating keys, recreating app but issue still persists.

My POST request from POSTMAN for registering webhook is as follows -

https://api.twitter.com/1.1/account_activity/all/DT/webhooks.json?url={My_URL}

Header -
Content-Type - application/x-www-form-urlencoded
Authorization - OAuth oauth_consumer_key="",oauth_token="",oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“1530093081”,oauth_nonce=“GoyeXPGJEet”,oauth_version="",oauth_signature=“TVnUrb7GR%2Bqb%2Fs2BsysOeA%3D”

Please help me sorting this out. Any help will be appreciated.

Thanks,
Sharad


#2

Looks like you need a user token and secret on that call as well?


#4

Hi Andy,

Thanks for your reply,
Could you please suggest from where I can get these tokens and by what name in header I should pass those.


#5

Hi Andy,

Do you mean Access token and Token secret keys.

As I do adding those values in header as below,

I get success on get account activity webhook API with 200 code but with an empty array.
https://api.twitter.com/1.1/account_activity/all/:env_name/webhooks.json

Please suggest.

Thanks,
Sharad


#6

If you have a 200 status code that’s a good sign. What’s your issue after that?


#7

Hi @andypiper,

I am getting success on GET call(Get registered webhooks) but on POST call(register a webhook) it’s given above error.

I did some analysis and seems like POSTMAN related issue as when I call same API from SOAP UI, its giving me below response,

{“errors”: [{
“code”: 214,
“message”: “Webhook URL does not meet the requirements. Invalid CRC token or json response format.”
}]}

ans sometimes it returns as below,
{“errors”: [{
“code”: 214,
“message”: “High latency on CRC GET request. Your webhook should respond in less than 3 seconds.”
}]}

When I run my CRC check API locally it gets executed within 3 secs.

Could you please suggest how to resolve this one.

Thanks,
Sharad


#8

I guess testing that locally it probably would show fast. What are you running to check that?


#10

I checked it online on one which gives API response time.


#11

The high latency CRC error has been very reliable. I’m guessing that you are indeed having moments where the response time is beyond 3 seconds.

As for the other error, have you made sure to follow our guidelines listed in the docs.:

_Create a web app with a URL to use as your webhook to receive events. This is the endpoint deployed on your server to listen for incoming Twitter webhook events. _
The URI path is completely up to you. This example would be valid: https://mydomain.com/service/listen
If you are listening for webhooks from a variety of sources, a common pattern is: https://mydomain.com/webhook/twitter
Note that the specified URL can not include a port specification (https://mydomain.com:5000/NoWorkie).

I also recommend that you review our section, Additional security guidelines, on this page.


#12

Hi @LeBraat,

Thanks for your reply.

As per my knowledge, I have referred the guidelines for developing and securing webhook.

Could you please suggest any other work around. I have already spend lot of time in this but no success yet.

Thanks,
Sharad Gadhe