![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
nr-linkedin-browser
Advanced tools
Connect to Oauth providers using Apache Cordova, Angular 2, and the InAppBrowser plugin
nr-linkedin-browser is an Oauth library which easily integrates in Angular2/Ionic2 or any other WEB or Cordova applications. The purpose of this library is to quickly and easily obtain an access token from various web services to use their APIs.
For Cordova application:
For Web application:
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 {Facebook, Google} 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
}
}
Each web service API acts independently in this library. However, when configuring each web service, one thing must remain consistent.
Currently it supports several oAuth providers: Facebook, Instagram, LinkedIn, Google, Meetup, Imgur. Example of creating oAuth provider:
const provider = new Facebook({
clientId: string,
appScope?: string[],
redirectUri?: string,
responseType?: string,
authType?: string
});
Each API call returns a promise. The success callback will provide a response object and the error callback will return an Error
object. Not all providers use implicit grants. Any provider that uses an explicit grant will return a code
rather than an access_token
. The code
must be
further exchanged server side for an access_token
. This is for the safety of your users.
const oauth = new OauthCordova();
const provider = new Facebook({
clientId: "CLIENT_ID_HERE",
appScope: ["email"]
})
oauth.logInVia(provider).then((success) => {
console.log(JSON.stringify(success));
}, (error) => {
console.log(JSON.stringify(error));
});
As of Apache Cordova 5.0.0, the whitelist plugin must be used in order to reach external web services.
Now this library can work with a web browser, ionic serve, or ionic view in case if you use OauthPlatform
service but do not forget to replace it with correct one for cordova project (i.e., OauthCordova
)
Google, as of October 2016, has started blocking requests from web views commonly found in hybrid applications. For this reason, support for Google has been removed from this library.
More information can be found at:
https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html
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);
});
});
}
Alternatively you can inject OauthCordova
in constructor as shown in examples above.
Browser's window.open
and Cordova's InAppBrowser supports bunch of options which can be passed as a second argument to logInVia
. For example if you don't know want to clear session cache, or place toolbar at the top for iOS:
new OauthCordova().logInVia(facebookProvider, {
clearsessioncache: 'no',
toolbarposition: 'top'
})
FAQs
Connect to Oauth providers using Apache Cordova, Angular 2, and the InAppBrowser plugin
We found that nr-linkedin-browser 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.