LinkedIn Authentication

Setup

Create a LinkedIn App

The first step in setting up your LinkedIn authentication integration is to create an app on LinkedIn.

Redirect URL, Consumer Key & Secret

App Implementation

Setup

Plugin Installation

The InAppBrowser plugin is used to login your users with LinkedIn authentication.

$ cordova plugin add cordova-plugin-inappbrowser --save

Injecting Auth and User

Import Auth and User from the Cloud Client and specify them as dependencies in your component constructor.

  • auth is a service that deals with user authentication.
  • user is a reference to the current user, whether that user is anonymous or authenticated.
import { Component } from [email protected]/core';
import { Auth, User } from [email protected]/cloud-angular';

@Component( ... )
export class LoginPage {
  constructor(public auth: Auth, public user: User) {
    ...
  }
}

Specify ionic.cloud as a dependency for your module. This gives you access to $ionicAuth and $ionicUser.

  • $ionicAuth is a service that deals with user authentication.
  • $ionicUser is a reference to the current user, whether that user is anonymous or authenticated.
angular.module('myapp.controllers', ['ionic.cloud'])

.controller('MyCtrl', function($scope, $ionicAuth, $ionicUser) {
  ...
})

Login

this.auth.login('linkedin').then( ... );
$ionicAuth.login('linkedin').then( ... );

Logout

Logging out clears the current user context.

this.auth.logout();
$ionicAuth.logout();

Social Data

We store social data in user.social.linkedin. Unlike your custom data which uses user.get() and user.set(), user.social.linkedin is just an object with the following properties.

uid LinkedIn user ID
data LinkedIn data object
data.profile_picture LinkedIn profile picture
data.full_name User’s full name
data.raw_data The data object straight from LinkedIn (see these docs)

Examples:

const full_name = this.user.social.linkedin.data.full_name;
const profile_picture = this.user.social.linkedin.data.profile_picture;
const linkedin_raw_data = this.user.social.linkedin.data.raw_data;
var full_name = $ionicUser.social.linkedin.data.full_name
var profile_picture = $ionicUser.social.linkedin.data.profile_picture
var linkedin_raw_data = $ionicUser.social.linkedin.data.raw_data;

Services

    API

      General