Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization failed Error Domain=WebKitErrorDomain Code=101 "(null) #69

Open
Allansk2 opened this issue Mar 15, 2016 · 0 comments
Open

Comments

@Allansk2
Copy link

Hi, all
I have a view controller trying to login linkedin and post. But I couldn't get login, have the error message "Authorization failed Error Domain=WebKitErrorDomain Code=101 "(null). Really frustrated, hoping someone could help me! Thanks.

Here is my code
ViewController.h

import <UIKit/UIKit.h>

import "LIALinkedInApplication.h"

import "LIALinkedInHttpClient.h"

@interface ViewController : UIViewController

@Property (nonatomic, strong) LIALinkedInHttpClient *client;

  • (IBAction) linkedInClicked:(id)sender;
  • (void)requestMeWithToken:(NSString *)accessToken;

@EnD

ViewController.m

import "ViewController.h"

@interface ViewController ()

@EnD

@implementation ViewController

  • (void)viewDidLoad
    {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    LIALinkedInApplication *application = [LIALinkedInApplication applicationWithRedirectURL:@"http://www.google.com" clientId:@"" clientSecret:@"" state:@"something" grantedAccess:@[@"r_fullprofile", @"rw_nus", @"w_share"]];
    self.client = [LIALinkedInHttpClient clientForApplication:application presentingViewController:nil];

}

  • (IBAction) linkedInClicked:(id)sender { // Login into the account
    [self.client getAuthorizationCode:^(NSString *code) {
    [self.client getAccessToken:code success:^(NSDictionary *accessTokenData) {
    NSString *accessToken = [accessTokenData objectForKey:@"access_token"];
    [self requestMeWithToken:accessToken];
    } failure:^(NSError *error) {
    NSLog(@"Quering accessToken failed %@", error);
    }];
    } cancel:^{
    NSLog(@"Authorization was cancelled by user");
    } failure:^(NSError *error) {
    NSLog(@"Authorization failed %@", error);
    }];
    }
  • (void)requestMeWithToken:(NSString *)accessToken {
    [self.client GET:[NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~?oauth2_access_token=%@&format=json", accessToken] parameters:nil success:^(AFHTTPRequestOperation *operation, NSDictionary *result) {
    NSLog(@"current user %@", result);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"failed to fetch current user %@", error);
    }];
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant