Skip to content

Twitter 406 error code

20 January 2012

Integrating with social sites, such as twitter, seems to be so easy, and it actually can be, once you get the configuration set up correctly. Last day however, I spend most of my time trying to hunt down a 406 error code when trying to login using a twitter account. According to the twitter site I have to :

  • Think of a name for my application that wants to use the twitter login, well that was not too hard
  • Enter a description
  • Tell on which domain your twitter application will be hosted, but you can enter a placeholder for this if you don’t know that yet, or want to test

And then you should be set and ready to go.

Twitter will then provide you with 2 keys that you need to use to communicate with twitter. Since there are already many libraries available that will take care of the communications for you with twitter, it looks like that was all that I needed to do. Started a webapp, using the playframework and the SecureSocial module and logged in using twitter. Or at least, I tried to login with twitter. Unfortunately, I was not allowed to login, since twitter returned me a 406 error:

WARNING: POST request for "" resulted in 406 (Not Acceptable); invoking error handle

Checked it at the twitter error codes and it says :

406 Not Acceptable: Returned by the Search API when an invalid format is specified in the request.

Which is weird since I did not try to use the search api, I was trying to signin with the given keys. Googling around this error I ran into a number of solutions, none of them really worked for me, but after trying out a combination of solutions I finally got it working. This is what I had to do:

  • Allthough it is not required, you have to give a callback url. This url should be back to localhost but that is not a valid domain according to twitter. So I set the callback url to
  • Changed my /etc/hosts file where will now return the ip address of localhost

and now it was working. I could finally login. I think the 406 code explanation should be altered a bit to indicate that it might also be a configuration issue.

I found out later today that I could also have solved this by setting the callback url to

Hope this helps someone sometime


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: