AFOAuth2Client is an extension for AFNetworking that greatly simplifies the process of authenticating against an OAuth 2 provider.
NSURL *url = [NSURLURLWithString:@"http://example.com/"]; AFOAuth2Client *oauthClient = [AFOAuth2Client clientWithBaseURL:url clientID:kClientIDsecret:kClientSecret]; [oauthClient authenticateUsingOAuthWithPath:@"/oauth/token"username:@"username"password:@"password"success:^(AFOAuthCredential *credential){NSLog(@"I have a token! %@", credential.accessToken); [AFOAuthCredential storeCredential:credential withIdentifier:oauthClient.serviceProviderIdentifier]} failure:^(NSError *error){NSLog(@"Error: %@", error)}];Mattt Thompson
AFOAuth2Client is available under the MIT license. See the LICENSE file for more info.