36

Logcat:

12-05 23:37:01.721:W/System.err(534):  401:Authentication credentials  (https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set valid     conumer key/secret, access token/secret, and the system clock in in sync.
12-05 23:37:01.721: W/System.err(534): 401:Authentication credentials (https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set valid conumer key/secret, access token/secret, and the system clock in in sync.
12-05 23:37:01.721: W/System.err(534): error - Read-only application cannot POST
12-05 23:37:01.721: W/System.err(534): request - /1/statuses/update.json

Though i can read the screen name by (getScreenName() function) and set read,write permission to my twitter application , it gives the above logcat.And i am using twitter4j jar file.

logankilpatrick
  • 13,148
  • 7
  • 44
  • 125
sayem siam
  • 1,281
  • 3
  • 13
  • 26
  • Looks like you didn't include the authentication data for an account. Post your code. – Ted Hopp Dec 05 '11 at 18:13
  • Here is my full code http://stackoverflow.com/questions/8382021/i-am-trying-to-update-status-to-twitter-using-twitter4j-jar-but-it-does-not-work – sayem siam Dec 05 '11 at 18:22
  • Please don't repost the same question. – Ted Hopp Dec 05 '11 at 18:26
  • But i did not get answer at that time and really stuck with this problem . i seen all documentation to do code right way.But it does not work – sayem siam Dec 05 '11 at 18:30
  • That question is only 11 hours old. Read [the faq](http://stackoverflow.com/faq#bounty) about what to do when you don't get an answer. – Ted Hopp Dec 05 '11 at 18:49

9 Answers9

75
  • Login in your app: http://dev.twitter.com/apps
  • In the Settings tab, change the Application type to Read, Write and Access direct messages
  • In the Reset keys tab, press the Reset button, update the consumer key and secret in your application accordingly.

It looks like that resetting the keys force the change to your application type to take effect.

Hemangi Gokhale
  • 700
  • 6
  • 11
Benjamin Crouzier
  • 40,265
  • 44
  • 171
  • 236
  • 4
    I'm not sure why, but resetting my consumer key and secret didn't fix this problem for me trying to send Direct Messages to people, I still got the "Read-only application cannot POST", despite restarting my application, manually revoking the App and authorising it again, and re-running the test. Eventually I recreated my access token ("Recreate my access token" button on the App 'Details' pane on dev.twitter.com) and the Direct Message could be sent. I can't say whether this was required, or if the Consumer key/secret reset worked and I simply didn't wait long enough for it to take effect. – Neek Nov 08 '12 at 03:58
  • 6
    After you modify your permissions, you have to regenerate the access-token and access-token-secret. – user3732708 May 16 '18 at 06:45
24

2022 UPDATE

all previously posted solutions don't work anymore. Here is the current solutiuon:

  1. select your app
  2. edit auth settings
  3. enable OAuth1
  4. select required permissions
  5. Enter the call back URL (it can be anything)
  6. Re-generate API Token (NOTE: you must do this or this process will not work)

dashboard (step 1+2)

enter image description here

settings (step 3+4)

enter image description here

logankilpatrick
  • 13,148
  • 7
  • 44
  • 125
dcts
  • 1,479
  • 15
  • 34
  • 1
    This is the only way to go since 2022. Forget all other explanations. – Edd Aug 20 '22 at 19:27
  • Now at the end of 2022 it's OAuth 2.0 but everything else in this answer is still accurate, thanks! – Veve Oct 28 '22 at 20:03
3

Go to https://dev.twitter.com/ -> My Applications -> "go to your current application" -> Setting -> Give the permission for "Read, Write and Direct Access" -> Save it. After that uninstall your project from emulator or device, -> Clean project -> Run Project.

Hope it will helpful. try this one:

3

Steps to follow for this problem.

Login with

https://dev.twitter.com/apps and go to settings

and Change the permission Read-only to

Read, Write and Access direct messages

and update page. and if in case not able to update then Re-Create the Token and try again problem will be solved..

Kishan Bheemajiyani
  • 3,429
  • 5
  • 34
  • 68
2

May be issue with your twitter application: Write Permission may remaining is it creates problem:

Go to https://dev.twitter.com/ -> My Applications -> "go to your current application" -> Setting -> Give the permission for "Read, Write and Direct Access" -> Save it. After that uninstall your project from emulator or device, -> Clean project -> Run Project.

Hope it will helpful:

user2368799
  • 1
  • 1
  • 2
2

You also have to revoke your old permission after you reset your permission.

  1. Go to https://twitter.com/settings/applications
  2. Find your app and you will see that it has read permission
  3. Revoke the access
Rubin Yoo
  • 2,674
  • 2
  • 24
  • 32
2

Adding to @Hemangi answer, you dont have to regenerate the consumer keys and secret. In your twitter developer portal go to the Keys and Tokens tab and check the access token

enter image description here

If it says created with only Read Only permissions, regenerate the Access Token and Secret and update the same in your code.

enter image description here

  • i did it but created same... just read only permission – Ateş Danış Mar 18 '22 at 10:36
  • 1
    @AteşDanış you have to give write permissions to your project and then regenerate the tokens. Go to Your Project>Settings> User Authentication Settings >App permissions. Change it from Read to Read and Write – Vignesh Nandakumar Mar 19 '22 at 11:14
0
  1. Go to portal
  2. Option: Projets & Apps tab.
  3. Inside this Option, go Setting, the App Permissions and change Read-only to Read + Write + Post Read Direct Messages
  4. Save
  5. Finally, go to the Keys and Tokens tab and regenerate only the Access token and Secret
Ganesh MB
  • 1,109
  • 2
  • 14
  • 27
0

Have you registered your application with twitter to get your consumer-secret key?

flyingCaffine
  • 382
  • 1
  • 4
  • 9