Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

AFOAuth1Client to authenticate received 404 #117

Open
phamdacloc opened this issue Oct 31, 2016 · 0 comments
Open

AFOAuth1Client to authenticate received 404 #117

phamdacloc opened this issue Oct 31, 2016 · 0 comments

Comments

@phamdacloc
Copy link

On my wordpress site, I have two plugins installed WP REST API (version 2.0-beta15) and WP REST API - OAuth 1.0a Server (version 0.3.0).

On my iOS app, I'm using AFNetworking and AFOAuth1Client to authenticate the app but I'm receiving the 404 error.

Here is the code I was testing:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    self.window.rootViewController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
    [self.window makeKeyAndVisible];

    self.twitterClient = [[AFOAuth1Client alloc] initWithBaseURL:[NSURL URLWithString:@"http://example.com/wp-json/"] key:@"WP Key" secret:@"WP secret"];

    [self.twitterClient authorizeUsingOAuthWithRequestTokenPath:@"/oauth1/request_token" userAuthorizationPath:@"/oauth1/authorize" callbackURL:[NSURL URLWithString:@"af-twitter://success"] accessTokenPath:@"/oauth1/access_token" accessMethod:@"POST" scope:nil success:^(AFOAuth1Token *accessToken, id responseObject) {

        [self.twitterClient registerHTTPOperationClass:[AFJSONRequestOperation class]];
        [self.twitterClient getPath:@"statuses/user_timeline.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
            NSArray *responseArray = (NSArray *)responseObject;
            [responseArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                NSLog(@"Success: %@", obj);
            }];
        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            NSLog(@"Error: %@", error);
        }];
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];

    return YES;
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation
{
    NSNotification *notification = [NSNotification notificationWithName:kAFApplicationLaunchedWithURLNotification object:nil userInfo:[NSDictionary dictionaryWithObject:url forKey:kAFApplicationLaunchOptionsURLKey]];
    [[NSNotificationCenter defaultCenter] postNotification:notification];

    return YES;
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant