Failed to validate OAuth signature and token


I am using following code to handle twitter integration in my Application.

GTMOAuthAuthentication *auth = [self authForTwitter];
[auth setCallback:@“”];

GTMOAuthViewControllerTouch *viewController;
viewController = [[GTMOAuthViewControllerTouch alloc] initWithScope:scope
appServiceName:@"CK12: Twitter"

  • (GTMOAuthAuthentication *)authForTwitter {

GTMOAuthAuthentication *auth = [[GTMOAuthAuthentication alloc] initWithSignatureMethod:kGTMOAuthSignatureMethodHMAC_SHA1

[auth setServiceProvider:@“Twitter”];

return auth;
My problem is, if I am changing device time i.e making it 1 hour late, then I am getting following error:

Error Code=401 and error message is : failed to validate oauth signature and token .
So can anybody please suggest how to solve this. if system time is wrong then also I want to make it work .


You won’t be able to sign your requests if the system time is incorrect. You’ll need to adjust the system’s clock or the oauth_timestamp value you use to make it correct. One way to do this is to use NTP on the system. Another approach is to make a HTTP HEAD request to an endpoint on – you’ll get a Date HTTP header in the response that indicates the current time understood by Twitter. You would then convert this to epoch time and adjust your oauth_timestamp values by a determined offset. You wouldn’t want to sync a clock like this more than once every few hours, so you’d also want to find a way to persist this adjustment.


Thank you for reply . . . i am very new to this twitter integration and I don’t know how to request for date header . can you please share some code for requesting date HTTP Header from twitter server in ios. . .