Twitter webhook registration

restapi
webhooks

#1

I am trying to register a webhook to receive events. But I am getting an error in response as below:

{
    "errors": [
        {
            "code": 261,
            "message": "Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform."
        }
    ]
}

I am using application only authentication to perform OAuth2. I am using node js oauth package for this.
What can be the issue here?


#2

Check this thread. You will want to use user access tokens to register (with OAuth 1.0A).

We have a node-based sample if you’d like to compare code.


#3

Thanks @andypiper . I missed the account activity api activation form submission. I have submitted the same. Approximately how long does it take for the activation?


#4

It can take a couple of weeks depending on the current volume of requests. We appreciate your patience.


#5

Hello @andypiper,
I did request for two Twitter Applications to get account activity API activated. I received an email notifying that the account activity API is activated for my app (but I didn’t get which of the two apps was activated as there was no consumer key mentioned in the email). After this email I tried to register the webhook trying with credentials of both the apps but I am getting the below error.

{
    "errors": [
        {
            "code": 261,
            "message": "Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform."
        }
    ]
}

Can you please help me out with this?


#6

Any updates on this @andypiper? Let me know if any info like consumer key, etc is required our end.


#7

Please don’t share app keys in public forums :slight_smile:

Unfortunately we cannot help you with individual apps via the forums as private information is needed. You’ll need to go via the platform support forms linked in the error to check here. The error you are seeing would seem to indicate that your app key(s) do not have write privileges, so it would be best to double-check that you’ve got the right ones activated.


#8

I am getting the same issue
[{“code”:261,“message”:"Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform."}]

Can somebody help me?
My Consumer key is : BPntVVFQDCBjl7WPSoyhYFW16


#9

I am also facing this issue.

My app is approved for Beta activities.

Anyone who can help?


#10

@andypiper can you help me with this.


#11

Seems to use application-only authentication.
Try user context authentication.


#12

@momentring

How to use user context authentication, can you send examples or link of that.


#13

https://developer.twitter.com/en/docs/basics/authentication/guides/single-user.html

Python implementation

CONSUMER_KEY = 'YOUR CONSUMER KEY'
CONSUMER_SECRET = 'YOUR CONSUMER SECRET'
ACCESS_TOKEN = 'YOUR ACCESS TOKEN'
ACCESS_TOKEN_SECRET = 'YOUR ACCESS TOKEN SECRET'
CALLBACK_ADDRESS = 'CALLBACK ADDRESS TO REGISTER'

def oauth_req(url, key, secret, http_method='GET', post_body='', http_headers=None):
    consumer = oauth2.Consumer(key=CONSUMER_KEY, secret=CONSUMER_SECRET)
    token = oauth2.Token(key=key, secret=secret)
    client = oauth2.Client(consumer, token)
    resp, content = client.request(url, method=http_method, body=post_body, headers=http_headers)
    return content

post_body = 'url=' + CALLBACK_ADDRESS
oauth_req('https://api.twitter.com/1.1/account_activity/all/env-beta/webhooks.json', ACCESS_TOKEN, ACCESS_TOKEN_SECRET, 'POST', post_body)

#14

@momentring

Its showing error {"errors":[{"code":200,"message":"Forbidden."}]}

Is there any http_headers perameters in this?


#15

No.
I guess you don’t have permission to access the Account Activity API.
Please check the link below.

https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/overview


#16

I already applied for Apply for Account Activity API beta access and I got email from twitter that your application has been approved for beta access with env_name : env-beta

I don’t know why this error occur again and again, I tried to register with php and python, but error is coming in both the format…

If I don’t have permission of Account Activity API then how can I check this?


#17

Perhaps you access wrong url.
The right one is ‘https://api.twitter.com/1.1/account_activity/all/env-beta/webhooks.json’ (no colon before ‘env-beta’).


#18

I already tried with above url as well. but didnt find solution.

Is there any way to check that my api has write permission?


#19

I believe permission will be given if receive email.
I only know granted users can access their developer dashboard (https://developer.twitter.com/en/dashboard).
If that page is available you must be able to use AAAPI, or it might be better to ask Twitter staff.


#20

See below image of my account dashboard.