angular-linkedin-sdk
An Angular (Angular 2 & Angular 4) wrapper for LinkedIn official Javascript SDK. To know more about the official documentation please visit here.
All features of the original Javascript SDK are available through the service LinkedInService
. The IN.Event.on(..)
and IN.Event.onOnce(...)
handler registration methods aren't exposed from original API, because you should subscribe to the isInitialized$
and isUserAuthenticated$
observables instead.
This library is published in an early state. The exposed interfaces might still be subject to change. Please don't expect a stable interface before version 0.2.x
Demo
To try the out the demo project clone the repository and run
$ npm install
Edit the demo/src/app/app.module.ts and paste you own LinkedIn API key
,
followed by
$ npm run-script demo
Install
$ npm install angular-linkedin-sdk
ES2015 / UMD
If your project is based on Angular CLI / WebPack everything will work as expected.
SystemJS / UMD support is not yet available, but planned for version 0.2.x
Angular Universal
Server side rendering is not supported, since the original LinkedIn Javascript SDK is using JSONP and can't run outside browser environments.
We are working on browser-agnostic support for the library. As mentioned it's not up to us to support server side rendering but in future release we will avoid initialization on non-browser platforms to make the library invisible. It might cause crashes in Angular Universal environments because of DOCUMENT and window object usage. You can specify whether to run in browser or server in the providers as seen in the Usage example.
Usage
In the Angular AppModule
:
;;; // Import the library;
LinkedInService
;
API
isInitialized
An observable that emits true and completes when library has finished loading.
Example
public subscribeToisInitialized
isUserAuthenticated
An observable that has an initial value of undefined. It emits a boolean value when the library has finished loading and when a login or logout is performed.
Example
ngOnInit
getSdkIN
Gets the IN variable from the LinkedIN SDK. Allows access to variables from the SDK that are or are not documented officially.
Example
public getApiKeyFromSdkIN
login
Returns an observable that emits true and completes when authenticated. Waits for the library to finish loading. isUserAuthenticated$ also emits an updated value.
Example
public subscribeToLogin
logout
Returns an observable that emits with no value and completes when logout is finished. Waits for the library to finish loading. isUserAuthenticated$ also emits an updated value.
Example
public subscribeToLogout
raw
Enables authenticated calls to the LinkedIn REST API using the generic call wrapper. The original fluent API is fully encapsulated.
Parameters
url
The API URL to invoke: should not includehttps://api.linkedin.com/v1
.
Example
public rawApiCall
refresh
Refreshes a member token for an additional 30 minutes. Repeated continual use of the refresh() function to keep a member indefinitely logged in can result in your application being disabled. Use this call sparingly.
Example
public refresh
Contribution
We are always looking for quality contributions and will be happy to accept your Pull Requests. For now, please make sure your PR has accompanying tests and all the tests are passing.
We will setup a CI system for the build very soon.
License
MIT © Evodeck Software