Custom callback fails with "Failed to validate oauth signature and token"


I originally set my account to use the oob callback. Works perfectly, can login and tweet from the app. Now when I change the callback to a custom value, say, myapp://oauth I get a 401 error with “Failed to validate oauth signature and token” in the response string. I’ve already put a placeholder URL in the application settings. What am I missing?


Hopefully you’re using header-based OAuth rather than query-string based OAuth, as it will make this part easier.

Make sure that when your signature base string is built that the custom oauth_callback value is properly escaped. If it were “myapp://oauth”, it should be presented as “myapp%3A%2F%2Foauth” in the OAuth signature basestring.


Yes, I am using headers. Will check the base string, thanks.


Here are what the base strings look like:

Working, callback = oob:


Not working, callback = oauth://callback



And what’s the exact URL you’re executing when issuing the request? Do you include any query parameters on the URL itself or in the POST body?


Your oauth_callback value is only escaped once in your base string. It needs to be escaped twice at the point it reaches the SBS.

This is true of every parameter you sign, actually, but the :// in the second request is the only portion which would actually be escaped, hence breaking only that request.


That was it, thanks!


It’s, no parameters nor post body.


hi , I am also stuck at the same issue.I have taken care of handling base string as described with no luck.

can update if it worked for you after escaping the callback twice…

Thanks,Any pointers would be appreciated.


Yes, it does work now. Make sure you have a placeholder URL for the callback in your app settings.


Thanks for the reply,but i already have the callback url set in the twitter app settings and am setting the same value as well in the CALLBACK URL in the application as well while forming the base string.

and request token URL used is -

I have no clue why it is failing now.Need your help for getting this up as i am running under a deadline.
Appreciate your inputs.


Issue resolved.Thanks
Can reach out in case of any inputs needed for anyone.


Here is my querystring.


Please someone help if what I am doing wrong in this. I am getting “Failed to validate oauth signature and token”