我正在尝试通过AFOAuth2Client 库使用完整的 Instapaper API ,但我不断收到错误代码 401。我不知道我的代码有什么问题。当我从电子邮件中复制和粘贴它们时,我绝对拥有正确的 ID 和秘密。
- (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]);
}];
}