I am using Twitter digits in my app. When the user signs into Digits, I save the auth token, auth token secret, userId, and phone number in the user’s keychain. On every launch, I make a call to account/verify_credentials endpoint to verify the user’s credentials. After the user signs in, every time I try to authenticate the user’s credentials, I get a 401 error, with a 32 error code. Here is the response I receive:
<NSHTTPURLResponse: 0x17ec18f0> { URL: https://api.twitter.com/1.1/account/verify_credentials.json } { status code: 401, headers {
"Content-Encoding" = deflate;
"Content-Length" = 76;
"Content-Type" = "application/json;charset=utf-8";
Date = "Sat, 27 Dec 2014 22:24:34 UTC";
Server = "tsa_a";
"Strict-Transport-Security" = "max-age=631138519";
"x-connection-hash" = ae27b1aa0d5e35c86ae3494d3d1bf5ec;
"x-response-time" = 7;
} }
Here is my code for sending the request:
NSString *authToken = [SSKeychain passwordForService:kDigitsAuthToken account:kRLTwitterAuth];
NSString *authTokenSecret = [SSKeychain passwordForService:kDigitsAuthTokenSecret account:kRLTwitterAuth];
NSString *userId = [SSKeychain passwordForService:kDigitsUserId account:kRLTwitterAuth];
NSString *phoneNumber = [SSKeychain passwordForService:kDigitsPhoneNumber account:kRLTwitterAuth];
DGTSession *newSession = [[DGTSession alloc] initWithAuthToken:authToken authTokenSecret:authTokenSecret userID:userId phoneNumber:phoneNumber];
TWTROAuthSigning *oauthSigning = [[TWTROAuthSigning alloc] initWithAuthConfig:[Twitter sharedInstance].authConfig authSession:newSession];
NSDictionary *authHeaders = [oauthSigning OAuthEchoHeadersToVerifyCredentials];
NSString *requestURLString = authHeaders[TWTROAuthEchoRequestURLStringKey];
NSString *authorizationHeader = authHeaders[TWTROAuthEchoAuthorizationHeaderKey];
NSMutableURLRequest *request = [self requestForURL:requestURLString];
[request setValue:authorizationHeader forHTTPHeaderField:@"Authorization"];
Am I doing something wrong? This was working, but it stopped for some reason.