Skip to content

Instantly share code, notes, and snippets.

@bjallen
Last active January 4, 2016 18:38
Show Gist options
  • Save bjallen/8661617 to your computer and use it in GitHub Desktop.
Save bjallen/8661617 to your computer and use it in GitHub Desktop.
AFNetworking OAuth Password AccessToken Request
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{
@"grant_type": @"password",
@"client_id": @"0364d040df9582e47552857f4880031a91df6b416e64bf3507d7987b5c5e79cd",
@"client_secret": @"9aa6f73ba79bc2bfcf621fc5e7979e1f03123cd4c79853db6d419591aa668d35",
@"username": @"email",
@"password": @"password"
};
[manager POST:@"http://localhost:3000/mapi/oauth/token.json"
parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
//[3249:303] JSON: {
// "access_token" = f6319b43f7172a;
// emails = (
// "email"
// );
// "expires_in" = 7200;
// "first_name" = "b";
// "last_name" = "a";
// "primary_email" = "email";
// "refresh_token" = c878c44901;
// "token_type" = bearer;
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment