I'm trying to use the full Instapaper API via the AFOAuth2Client library but I keep getting the error code 401. I have no idea what's wrong with my code. I definitely ahve the right ID and secret as I copy and pasted them from the email.
- (IBAction)loginPressed:(UIButton *)sender {
NSURL *baseURL = [NSURL URLWithString:@"https://www.instapaper.com/"];
AFOAuth2Client *OAuthClient = [AFOAuth2Client clientWithBaseURL:baseURL
clientID:@"fromEmail"
secret:@"fromEmail"];
NSDictionary *parameters = @{
@"x_auth_username:" : self.usernameField.text,
@"x_auth_password:" : self.passwordField.text,
@"x_auth_mode:" : @"client_auth"
};
[OAuthClient authenticateUsingOAuthWithPath:@"api/1/oauth/access_token"
parameters:parameters
success:^(AFOAuthCredential *credential) {
NSLog(@"I has token! %@", credential.accessToken);
// [AFOAuthCredential storeCredential:credential withIdentifier:OAuthClient.serviceProviderIdentifier];
}
failure:^(NSError *error) {
NSLog(@"Sheet. %@", [error localizedDescription]);
}];
}
According to Instapaper's API docs:
OAuth 2 is different from OAuth 1, which is itself different from xAuth.
AFOAuth2Client
is not going to work here. You may have luck with eitherAFXAuthClient
orAFOAuth1Client
.