Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
nr-linkedin-login
Advanced tools
Readme
$ cordova plugin add https://github.com/nithinkumarhere/nr-cordova-linkedin.git --variable APP_ID=YOUR_APP_ID
$ npm install --save nr-linkedin-login
Plugin Repo: https://github.com/nithinkumarhere/nr-cordova-linkedin
A Cordova plugin that lets you use LinkedIn Native SDKs for Android and iOS.
Please see the plugin's repo for detailed installation steps.
import { LinkedIn } from '@ionic-native/linkedin';
constructor(private linkedin: LinkedIn) { }
...
// check if there is an active session
this.linkedin.hasActiveSession().then((active) => console.log('has active session?', active));
// login
const scopes = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];
this.linkedin.login(scopes, true)
.then(() => console.log('Logged in!')
.catch(e => console.log('Error logging in', e));
// get connections
this.linkedin.getRequest('people/~')
.then(res => console.log(res))
.catch(e => console.log(e));
// share something on profile
const body = {
comment: 'Hello world!',
visibility: {
code: 'anyone'
}
};
this.linkedin.postRequest('~/shares', body)
.then(res => console.log(res))
.catch(e => console.log(e));
From the root of your Apache Cordova project, execute the following:
npm install nr-linkedin-browser --save
This will install nr-linkedin-browser and its dependencies.
There are 2 types of entities in the library: Platform (i.e., Cordova, Browser) and Provider (i.e., Facebook, LinkedIn, etc.). Each provider has it's own class. You need to inject the Platform class into every class in which you wish to use them. For example, if you wish to use Facebook oauth in a particular class, it would look something like:
import {LinkedInb} from 'nr-linkedin-browser/core';
import {OauthBrowser} from 'nr-linkedin-browser/platform/browser'
// or
import {OauthCordova} from 'nr-linkedin-browser/platform/cordova'
Alternatively you can use Angular2 Injector in order to provide platform specific service for all components:
import {bootstrap} from '@angular/platform-browser-dynamic'
import {App} from './app.component'
import {OauthCordova} from 'nr-linkedin-browser/platform/cordova'
import {Oauth} from 'nr-linkedin-browser/oauth'
bootstrap(App, [
{ provide: Oauth, useClass: OauthCordova }
])
// and later in component
@Component({
selector: 'my-component'
})
class MyComponent {
constructor(oauth: Oauth) {
this.oauth = oauth
}
}
const provider = new LinkedInb({
clientId: string,
appScope?: string[],
redirectUri?: string,
responseType?: string,
authType?: string
});
import { Component, OnInit } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { LinkedIn, LinkedInLoginScopes } from 'nr-linkedin';
import { LinkedInb } from "nr-linkedin-browser/core";
import {OauthCordova} from 'nr-linkedin-browser/platform/cordova';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage implements OnInit {
private loggedIn: boolean;
scopes: LinkedInLoginScopes[] = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];
isLoggedIn: boolean = false;
selfData = { id:"", firstName:"", lastName:"" };
private oauth: OauthCordova = new OauthCordova();
private linkedinbProvider: LinkedInb = new LinkedInb({
clientId: "814imsl6ap5wcn",
appScope: ["r_basicprofile","r_emailaddress"],
redirectUri: "http://localhost/callback",
responseType: "code",
state: "DCEeFWf45A53sdfKef424"
})
constructor(public navCtrl: NavController, private linkedin: LinkedIn, private platform: Platform) {}
public linkedinb() {
this.platform.ready().then(() => {
this.oauth.logInVia(this.linkedinbProvider).then(success => {
console.log("RESULT: " + JSON.stringify(success));
}, error => {
console.log("ERROR: ", error);
});
});
}
ngOnInit() {
}
ionViewDidAppear() {
this.linkedin.hasActiveSession().then((active) => {
this.isLoggedIn = active;
if(this.isLoggedIn === true) {
this.getSelfData();
}
});
}
login(){
this.linkedin.isLinkedInAppInstalled()
.then(res => {
if(res==false){
console.log("app not installed");
this.linkedinb();
}else{
console.log("app installed");
this.linkedin.login(this.scopes, true)
.then(() => {
this.isLoggedIn = true;
this.getSelfData();
})
.catch(e => console.log('Error logging in', e));
}
})
.catch(e => console.log(e));
}
logout() {
this.linkedin.logout();
this.isLoggedIn = false;
console.log(this.isLoggedIn);
}
getSelfData() {
this.linkedin.getRequest('people/~')
.then(res => {
this.selfData = res;
//this.openProfile(res.id);
console.log(res);
})
.catch(e => console.log(e));
}
openProfile(memberId) {
this.linkedin.openProfile(memberId)
.then(res => console.log(res))
.catch(e => console.log(e));
}
shareSomething() {
const body = {
comment: 'May I Share something on my profile?',
visibility: {
code: 'anyone'
}
};
this.linkedin.postRequest('~/shares', body)
.then(res => console.log(res))
.catch(e => console.log(e));
}
}
FAQs
A cordova linkedin plugin with native login style
The npm package nr-linkedin-login receives a total of 8 weekly downloads. As such, nr-linkedin-login popularity was classified as not popular.
We found that nr-linkedin-login demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.