I'm trying to access a single part of the Twitter API, without logging in a user account (application-only authentication is what I want), so I don't want to add some framework just to perform this one operation. I'm trying to do it with AFNetworking instead based on the description here: https://dev.twitter.com/oauth/reference/post/oauth2/token .
Here's what I have so far
AFOAuth2Manager *authManager = [[AFOAuth2Manager alloc] initWithBaseURL:[NSURL URLWithString:@"https://api.twitter.com/"]
clientID:TwitterAPIKey
secret:TwitterSecret];
[authManager authenticateUsingOAuthWithURLString:@"oauth2/token"
parameters:nil
success:^(AFOAuthCredential *credential) {
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:TwitterBaseURL]];
[manager.requestSerializer setAuthorizationHeaderFieldWithCredential:credential];
//do some stuff
}
failure:^(NSError *error) {
//handle the failure, where I'm currently ending up
}];
When run, this fails to authenticate with a 403 forbidden error. Can anyone explain to me where I'm going wrong?