Skip to content

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

Description

@Allansk2

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);
    }];
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions