0

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]);
                 }];
}
Doug Smith
  • 29,668
  • 57
  • 204
  • 388

1 Answers1

1

According to Instapaper's API docs:

Instapaper’s OAuth implementation is different from what you may be accustomed to: there is no request-token/authorize workflow. This makes it much simpler. Instead, Instapaper uses an implementation of xAuth very similar to Twitter’s. So you still need to sign your requests, but getting tokens is simple.

xAuth is the only way to get an Instapaper access token.

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 either AFXAuthClient or AFOAuth1Client.

Community
  • 1
  • 1
mattt
  • 19,544
  • 7
  • 73
  • 84
  • Ah, thanks mattt (I really appreciate your projects by the way). Rather annoying Marco decided to choose `oauth` in the URL scheme if it's xauth. That library worked perfectly. Thank you. – Doug Smith May 26 '13 at 22:33