Code Monkey home page Code Monkey logo

ngx-cordova-oauth's Introduction

Build Status PayPal Bitcoin

Angular 2 Cordova Oauth

ng2-cordova-oauth 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.

Donations

If you found this project useful, please consider donating some Bitcoin to the following address:

1M8SKTepmgA2KAUSZc7LpXN1owaky1DjNM

Requirements

For Cordova application:

For Web application:

  • webpack, systemjs or amd loaders

Installing ng2-cordova-oauth Into Your Project

Installing

From the root of your Apache Cordova project, execute the following:

npm install ng2-cordova-oauth --save

This will install ng2-cordova-oauth and its dependencies.

Injecting:

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 'ng2-cordova-oauth/core';
import {OauthBrowser} from 'ng2-cordova-oauth/platform/browser'
// or
import {OauthCordova} from 'ng2-cordova-oauth/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 'ng2-cordova-oauth/platform/cordova'
import {Oauth} from 'ng2-cordova-oauth/oauth'

bootstrap(App, [
  { provide: Oauth, useClass: OauthCordova }
])

// and later in component

@Component({
  selector: 'my-component'
})
class MyComponent {
  constructor(oauth: Oauth) {
    this.oauth = oauth
  }
}

Using ng2-cordova-oauth In Your Project

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)

Important Note About Google

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

A Working Example

import {Component} from '@angular/core';
import {NavController, Platform} from 'ionic-angular';
import {Facebook, Google, LinkedIn} from "ng2-cordova-oauth/core";
import {OauthCordova} from 'ng2-cordova-oauth/platform/cordova';

@Component({
    templateUrl: 'build/pages/home/home.html'
})
export class HomePage {

    private oauth: OauthCordova = new OauthCordova();
    private facebookProvider: Facebook = new Facebook({
      clientId: "CLIENT_ID_HERE",
      appScope: ["email"]
    })

    constructor(private navCtrl: NavController, private platform: Platform) { }

    public facebook() {
        this.platform.ready().then(() => {
            this.oauth.logInVia(this.facebookProvider).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.

Custom browser window options

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'
})

the list of all available options can be found:

Version History

Coming soon...

Contribution Rules

All contributions must be made via the development branch. This keeps the project more maintainable in terms of versioning as well as code control.

Have a question or found a bug (compliments work too)?

This project is maintained by Nic Raboy.

Tweet Nic Raboy on Twitter - @nraboy

Resources

Ionic 2 - http://www.ionicframework.com

Angular 2 - https://www.angular.io

Apache Cordova - http://cordova.apache.org

Nic Raboy's Code Blog - https://www.thepolyglotdeveloper.com

ngx-cordova-oauth's People

Contributors

edumiada avatar matheusrocha89 avatar nraboy avatar paullang avatar shanhaichik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-cordova-oauth's Issues

regular login?

as the title says, it would be nice if we have a regular login too.

Login with Strava

The current structure of your implementation doesn't allow IOauthProvider interface to be overwritten by a class that inherits OAuthProvider. I am completing the feature request #7. Strava requires two steps to get the token from their service. The first is the authenticating and then making a request for a token. Strava API sends a code after authenticating which then requires another request to fetch the token. Is it possible to get this fixed and override the login method for IOauthProvider?

Trouble with Untappd

I'm having an issue with Untappd where, after sign-in, I get an error back from Untappd stating that the redirect_url or client_id is missing. I'm not really sure how to debug this issue. If I call dialogUrl() on the class I implemented, the URL includes both of those parameters.

I know Untappd had an OOTB implementation in ng-cordova-oauth and I looked it it... didn't see anything out of the ordinary there.

`
// Start OAuth2
let oauth: OauthCordova = new OauthCordova();

interface IUntappedOptions extends IOAuthOptions {
}

let oauthProvider: OAuthProvider = new class extends OAuthProvider {
  protected authUrl: string = 'https://untappd.com/oauth/authenticate';
  protected defaults: Object = {
    responseType: 'token'
  };

  constructor(options: IUntappedOptions = {}) {
    super(options);
  }

}({clientId: 'xxxxxx'} );
console.log(oauthProvider.dialogUrl());

this.platform.ready().then(() => {
        oauth.logInVia(oauthProvider, {location:'yes', fullscreen: 'yes'}).then(success => {
            console.log("RESULT: " + JSON.stringify(success));
        }, error => {
            console.log("ERROR: ", error);
            this.showToast('Error linking Untappd');
        });
    });

`

Instagram not working anymore

The Instagram login is not working anymore, seems due to a cookie related issue. Once inserted username and password I excpect redirectUrl to be called, but insted I obtain this screen
screen shot 2018-05-23 at 17 38 51
in both Android and iOS devices.

This page could not be loaded. If you have cookies disabled in your browser, or you are browsing in Private Mode, please try enabling cookies or turning off Private Mode, and then retrying your action.

Is it a InAppBrowser related issue? Or does Instagram changed something after the latest Facebook policy changes?

The entire login process has been working until last week.

Can't resolve all parameters for CordovaOauth: (?).

Hi,
I tried to use your plugin with the lastest version of Ionic 2 and there's some unmet dependency.
Also when I'm trying to login the user with Google I get this message :
ORIGINAL STACKTRACE: Error: Can't resolve all parameters for CordovaOauth: (?). at new BaseException (http://192.168.0.24:8100/build/js/app.bundle.js:2892:23) at CompileMetadataResolver.getDependenciesMetadata (http://192.168.0.24:8100/build/js/app.bundle.js:14580:19) at CompileMetadataResolver.getTypeMetadata (http://192.168.0.24:8100/build/js/app.bundle.js:14461:26) at http://192.168.0.24:8100/build/js/app.bundle.js:14615:30 at Array.map (native) at CompileMetadataResolver.getProvidersMetadata (http://192.168.0.24:8100/build/js/app.bundle.js:14603:26) at CompileMetadataResolver.getDirectiveMetadata (http://192.168.0.24:8100/build/js/app.bundle.js:14412:34) at RuntimeCompiler.resolveComponent (http://192.168.0.24:8100/build/js/app.bundle.js:18308:47) at Tab.NavController.loadPage (http://192.168.0.24:8100/build/js/app.bundle.js:55441:24) at Tab.loadPage (http://192.168.0.24:8100/build/js/app.bundle.js:66776:35) ERROR CONTEXT: [object Object], http://192.168.0.24:8100/build/js/zone.js, Line: 260

Scope not working, please help

Hi, I tried using facebook and google, but it turns out that scope doesnt working, it returns only accesstoken for both of these

this.cordovaOauthFB = new CordovaOauth(new Facebook({clientId: "myid", appScope: ["email"]}));
this.cordovaOauthG = new CordovaOauth(new Google({clientId: "myid", appScope: ["email"]}));

example return
{"access_token":"EAAZAeHUMssqkBAAZCwNi99LVPV44NjGyiZCVC732POTZBBBN06m0xWjmLAUbFncqoXQ1YfZAsu0Sm1k2IoBGZCCSp7s9myH7uePGbrlIgfZAmjjRZA69t5g3AfgdSXM3Xr6VYEZD","expires_in":"5183380"}

Google OAuth no longer works due to restrictions

I tried using Google OAuth similar to this description: https://www.thepolyglotdeveloper.com/2016/01/use-ng2-cordova-oauth-for-all-your-ionic-2-oauth-needs
Instead of using Facebook, I tried Google and registered my app in the developer console. But it seems that it is not possible anymore to use Google OAuth embedded in a web view (https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html)

Is this a known issue and is there an other way to use Google as an identity provider?

[Problem] Twitter Implementation

Hi, I was trying to implement twitter oauth with this lib, but i have that problem: When I open https://api.twitter.com/oauth/authenticate? to get the oauth_verifier I get the problem: "This page is no longer valid. It's looks like someone already used the token information your provider, blabla.."

Im creating a Request token with node, like:

app.get("/auth/twitter/token", function (req, res) {

var requestTokenUrl = "https://api.twitter.com/oauth/request_token";
var requestTokenOauth = {
    consumer_key: "***********",
    consumer_secret: "***",
    callback: "***/auth/twitter/token"
};

request.post({
    url: requestTokenUrl,
    oauth: requestTokenOauth
}, function (err, response, body) {
       var oauthToken = qs.parse(body);
       res.send(oauthToken);
   });
});

With this i get the token and token secret, after I call the Twitter Login, thats my implementation:

"use strict";
var utility_1 = require("../utility");
var PROVIDER_NAME = "Twitter";
var Twitter = (function () {
    function Twitter(options) {
        this.twitterOptions = options;
        this.flowUrl = ""
    }
    Twitter.prototype.login = function (token, tokenSecret) {
        var _this = this;
        return new Promise(function (resolve, reject) {
            _this.flowUrl = "https://api.twitter.com/oauth/authenticate?oauth_token="+token;
            var browserRef = window.cordova.InAppBrowser.open(_this.flowUrl, "_blank", "location=no,clearsessioncache=yes,clearcache=yes");
            browserRef.addEventListener("loadstart", function (event) {
                if ((event.url).indexOf(_this.twitterOptions.redirectUri) === 0) { 
                    browserRef.removeEventListener("exit", function (event) { });
                    browserRef.close();
                    var parsedResponse = event.url.split("?")[1].split("&");
                    if (parsedResponse) {
                        resolve(parsedResponse);
                    }
                    else {
                        reject("Problem authenticating with " + PROVIDER_NAME);
                    }
                }

            });
            browserRef.addEventListener("exit", function (event) {
                reject("The " + PROVIDER_NAME + " sign in flow was canceled");
            });
        });
    };
    return Twitter;
}());
exports.Twitter = Twitter;

In the Component I Make:

this.API.twitterToken().subscribe(
    data => {
        alert(data.oauth_token)
        alert(data.oauth_token_secret)
        this.twitterOAuth.login(data.oauth_token, data.oauth_token_secret).then((success) => {
          alert(JSON.stringify(success))}, (error) => {alert(JSON.stringify(error));
            });
    },
  err => alert(JSON.stringify(err))
);

Someone can help? this can be a feature in the future

Issue with instagram in ionic 3

I have installed the plugin and added the code as following

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Instagram } from "ng2-cordova-oauth/core";
import { OauthCordova } from 'ng2-cordova-oauth/platform/cordova';
import { UserService } from '../../providers/user-service';

@component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {

private oauth: OauthCordova = new OauthCordova();

private instagramProvider: Instagram = new Instagram({
clientId: "2d####################9", // Register you client id from https://www.instagram.com/developer/
redirectUri: 'http://localhost', // Let is be localhost for Mobile Apps
responseType: 'token', // Use token only
appScope: ['basic', 'public_content']

/*
appScope options are 

basic - to read a user’s profile info and media
public_content - to read any public profile info and media on a user’s behalf
follower_list - to read the list of followers and followed-by users
comments - to post and delete comments on a user’s behalf
relationships - to follow and unfollow accounts on a user’s behalf
likes - to like and unlike media on a user’s behalf

*/

});

private apiResponse;

constructor(public navCtrl: NavController, public UserService: UserService) {
this.apiResponse = [];
}

ngOnInit() {
this.oauth.logInVia(this.instagramProvider).then((success) => {

  console.log(JSON.stringify(success));

  /* Returns User uploaded Photos */
  this.UserService.getInstagramUserInfo(success).subscribe(response => this.apiResponse = response.data);

}, (error) => {
  console.log(JSON.stringify(error));
});

}

}

I am redirected to insatgram login page ,but i always get an error as invalid username though i enter correct username and password.What am i doing wrong ,any inputs.

screenshot_1502791141

Reduce code duplication

So, there are 2 goals:

  • reduce code duplication through inheritance
  • add support for LinkedIn provider (this one is in separate issue)

Let me know if that sounds good. I will create an appropriate MRs

not getting any success data for google login through Ionic2

Hi Nrayboy,

I am able to login through google, but not getting any response in promises. It's throwing error, webpage not available. But it is showing access_token in error message and also not closing child window. I have tested in chrome, emulation and device in vain.

I also tried to open google using window.open(). I am able to open google. But whatever I write as a callback function within addEventListener() is not working.

Kindly help me.

Sample code
for Google auth--

let cordovaOauth = new CordovaOauth(
new Google({
clientId: "myClientId",
appScope: ["email"], "redirectUri": "http://localhost:8100/main.html"
}));

    //       //this.platform.ready().then(() => {
    cordovaOauth.login().then((success) => {
        this.txt1 = JSON.stringify(success);
        console.log(JSON.stringify(success));
    }, (error) => {
        this.txt1 = error;
        console.log(error);
    });

For google.com testing
this.loginWindow = window.open('http://google.com', '_blank','location=no,clearsessioncache=yes,clearcache=yes');
this.loginWindow.addEventListener('loadstart', (event) => console.log("done"), false);

core.js does not export CordovaOauth

Hello,

I am using your library in my ionic 2 app, but as soon as I upgraded to RC0, I started getting this weird error:

Error: Module .../node_modules/ng2-cordova-oauth/core.js does not export CordovaOauth (imported by .../.tmp/pages/login/login.js)

Any help is greatly appreciated. Thank you !

How to use and get YouTube scope after getting the token?

Here is my code

    let token: any;
    let fullData: any;
  const oauth = new CordovaOauth();
  const provider = new Google({
    clientId: "414008414674-i5gk49vnu5vcpjksc2mak50bljdimq5v.apps.googleusercontent.com",
    appScope: ["https://www.googleapis.com/auth/youtube"]
  })

  oauth.logInVia(provider).then(success => {

      console.log(success);

      let jString = JSON.stringify(success);
      let tokenObj = JSON.parse(jString); 

      token = tokenObj.access_token;
      let headers = new Headers();
      let googleAPI = "https://www.googleapis.com/youtube/v3/channels?part=brandingSettings%2C+snippet%2C+id%2C+statistics&mine=true";
      headers.append('Authorization', 'Bearer ' + token);
      headers.append('Content-Type', 'application/json');

      return this.http.get(googleAPI, { headers })
        .map(res => res.json())
        .subscribe(data => {

          console.log(data);

          fullData = {
            uid: "",
            email: "",
            photoURL: "",
            name: "",
            youtube_channel : data
          }



        })


  }, (error) => {
      console.log(JSON.stringify(error));
  }); 

But the token I got and use again to request the YouTube API info return 400 error. How can I request user YouTube info with googe?

Module or jsnext:main in package.json

Since this is a Typescript app, can you distribute es5 code (es5 target) with es2015 modules in addition to the commonjs modules you distribute?

Set the moduleResolution to node as well to make everything work well.

jsnext:main and module are the fields that point to the entrypoint for the es5 code with es2015 modules. Angular uses module and it seems most bundlers look for module, then jsnext:main, then main in that order.

Happy to help with the process if needed.

Thanks,
Dan

Tumblr Login is Working

HI Team,

I have created a provider for Tumblr, it seems it is not working any help

"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var provider_1 = require("../provider");
var Tumblr = (function (_super) {
    __extends(Tumblr, _super);
    function Tumblr(options) {
        if (options === void 0) { options = {}; }
        _super.call(this, options);
        this.authUrl = 'https://www.tumblr.com/oauth/access_token';
        this.defaults = {
            responseType: 'token'
        };
    }
    return Tumblr;
}(provider_1.OAuthProvider));
exports.Tumblr = Tumblr;

OauthBrowser Callback issue

Hi!

I'm a bit stuck with implementing this lib in my project.

Trying to debug it locally using ionic serve => using the OauthBrowser.

setup is pretty simple:

import {Facebook, Google} from 'ng2-cordova-oauth/core';

//replace for build!!!
import {OauthCordova} from 'ng2-cordova-oauth/platform/cordova'
import {OauthBrowser} from 'ng2-cordova-oauth/platform/browser'

@Injectable()
export class AuthServiceProvider {

  private oauth = new OauthBrowser();
  private fBprovider = new Facebook({
  clientId: "*620872*********",
  appScope: ['email']
});

  constructor(public http: Http, @Inject(APP_CONFIG) private config: IAppConfig) {
  }

  fbLogin() {
    return this.oauth.logInVia(this.fBprovider);
  }
}

Browser window is opened and i receive an access token in callback url, however it seems like the callback isn't getting processed by OauthBrowser, as in browser i'm getting error:

This site can’t be reached

localhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED

I don't have firewalls / other servers running.
Have http://localhost/callback and https://localhost/callback in Valid OAuth redirect URIs FB app's config.

config:

    @ionic/cli-utils  : 1.12.0
    ionic (Ionic CLI) : 3.12.0

global packages:

    cordova (Cordova CLI) : not installed

local packages:

    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.6.0

System:

    Node : v6.11.0
    npm  : 5.3.0 
    OS   : Windows 10

Why is this possibly happening?

Not working with ionic serve

If I launch the app with ionic serve:

  1. user press login button
  2. the popup with Instagram login page opens correctly
  3. user do the login
  4. the popup shows an error: localhost ERR_CONNECTION_REFUSED

It seems that the OauthBrowser doesn't detect that the url of the popup has changed to the callback uri.
Logging the popup.location.href in browser.js, inside the whatch cycle, the result is always "about:blank".

ng2-cordova-oauth ver 0.0.8
@ionic/cli-utils : 1.8.1
ionic (Ionic CLI) : 3.8.1
@ionic/app-scripts : 2.1.4
Ionic Framework : ionic-angular 3.6.1
Node : v6.11.0
npm : 5.3.0
OS : Linux 4.4

Ionic 2 - ng2 Cordova - Facebook Authentication - You are not logged in HTML

Hello,

Have you seen this before ? As soon as I execute the following code, I get the below result.

this.cordovaOauth = new CordovaOauth(new Facebook({clientId: "xxxx_app_id", appScope: ["email"]}));
        this.platform.ready().then(() => {
            this.cordovaOauth.login().then((success) => {
                console.log(JSON.stringify(success));
            }, (error) => {
                console.log(error);
            });
        });

screenshot_2016-06-04-10-26-38

Just to make sure, the clientID is the appID from the facebook developer portal ?

Thank you a lot.
Tony

Error loading login page of "Instagram"

I recently started getting an error with the instagram login. The window opens as expected and shows the instagram login form, however once entering my credentials and hitting Log in the window immediately closes before the authorization step and the error is: Error loading login page of "Instagram". Has anyone else run into this recently? It seems to happen if you've already approved the app.

Custom oauth2 provider support

If I create an OAuth2 Identity Server, will this plugin allow me to specify the relevant information to authenticate and retrieve an access token from my own server?

[Feature Request] Saving username in inapp browser login window

It could be nice if the username is saved and not asked to reenter when the inapp browser login window is opened again even after the access token has expired.

This feature is like on the normal desktop browser, the username can be used for the next session even after the browser is closed or the access token is expired.

Thanks.

'The sign in flow was canceled' due to return missing

When I connect via custom Provider, the popup dialog open and close immediatly because I was already authentified. Yet, I receive a reject('The sign in flow was canceled').
I saw (browser.js)

setTimeout(function watchPopup() {
                try {
                    if (popup.closed) {
                        return reject(new Error("The \"" + options.providerName + "\" sign in flow was canceled"));
                    }
                    if (popup.location.href.indexOf(options.resolveOnUri) === 0) {
                        popup.close();
                        resolve({ url: popup.location.href });
                    }
                }
                catch (e) {
                }
                setTimeout(watchPopup, watchDelay);
            }, watchDelay);

What's happen :

  • I receive the resolve
  • it continue the setTimeout,
  • the popup close
  • I receive the reject.

I add a return after the resolve, and it works.

Need to press "Done" button

On the end of user login process, the popup window does not close automatically until user press "Done" button (on iOS).

On console logs in auth frame I see this error:

http://localhost/callback#access_token=[...]&token_type=Bearer&expires_in=3600 Failed to load resource: Could not connect to the server.

After user press "Done" everything works as expected.
I am using ionic 2.1.0-beta.2
cordova-plugin-whitelist: 1.3.0
Also I am using cordova-plugin-wkwebview-engine.
ng2-cordova-oauth 0.0.6

CordovaAuth is not defined

I'm trying to use it with ionic2

mbmf:project user$ npm install git+https://[email protected]/nraboy/ng2-cordova-oauth --save
project@ /Users/user/project-app/project
└── [email protected]  (git+https://[email protected]/nraboy/ng2-cordova-oauth.git#bafe0608fc6ec7a5d5d6e8ad33b6293d84845aab)

npm WARN project@ No repository field.
npm WARN project@ No license field.
mbmf:project user$ ionic serve

Inside my js code i have

import {CordovaOauth, Facebook} from 'ng2-cordova-oauth/core';

When I'm trying to run it i get

EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in ./LoginPage class LoginPage_Host - inline template:0:0
ORIGINAL EXCEPTION: ReferenceError: CordovaAuth is not defined

Spotify not working

Hi , I can not import the spotify class. Is this class working?

spotify

"ng2-cordova-oauth": "0.0.8",

bundle failed: 'CordovaOauth'

Hi, thx for your work.

I have a problem CordovaOauth import not recognized.

[10:47:15] bundle failed: 'CordovaOauth' is not exported by node_modules/ng2-cordova-oauth/core.js (imported
by .tmp/pages/auth/auth.js). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
[10:47:15] ionic-app-script task: "build"
[10:47:15] Error: 'CordovaOauth' is not exported by node_modules/ng2-cordova-oauth/core.js (imported
by .tmp/pages/auth/auth.js). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module

Any Idea ?

[Feature Request] Strava

Love what's here so far. When you get the time an implementation to Strava would be appreciated.

Cannot connect to facebook (iOS only)

I am using Oauth Facebook Login, it works great with Android, but I am getting errors in iOS.
I have captured the errors, don't know what is happening.
Does anyone had the same issue?

Regards,
Luiz

oauth-error

When to expect new release

A lot of stuff were done in development branch, could you please update when this will be available publicly?

Cannot authenticate via web Browser

I just follow the examples and when compile the app to my phone(android) and click login it says that.
Somebody can help me? or tell me what is the right configuration in the facebook console.

my register component look like this.

import { Component, OnInit } from '@angular/core';
import { Facebook, Google, LinkedIn } from 'ng2-cordova-oauth/core';
import { OauthCordova } from 'ng2-cordova-oauth/platform/cordova';

@Component({
selector: 'app-register',
templateUrl: './register.component.html',
styleUrls: ['./register.component.scss']
})
export class RegisterComponent implements OnInit {
private oauth: OauthCordova = new OauthCordova();
private facebookProvider: Facebook = new Facebook({
clientId: '**********',
appScope: ['email']
});
constructor() {}

ngOnInit() {}

login() {
this.oauth.logInVia(this.facebookProvider).then(
success => {
alert('RESULT: ' + JSON.stringify(success));
},
error => {
alert('ERROR: ' + error);
}
);
}
}

my register.html like this

<div class="network col-12">
<button (click)="login()" class="btn btn-primary connect">Sign Up With Facebook</button>
</div>

Logout facebook

Hello,

I successfully implemented the Facebook login in my app.
Its working great, but I'm facing a problem with the logout.

There's no method to logout.

How can I logout or revoke an access token?

I tried to make a request to this endpoint:

https://graph.facebook.com/v2.7/{userID}/permissions?method=delete&access_token={acessToken}

This removes the permissions, but when trying to login again the user seems already logged in the inappbrowser and only have to confirm the permissions.

Linkedin connect fails

I'm getting this error when trying to login with linkedin:

The redirect_uri does not match the registered value.

This is my linkedin provider object:

  private linkedinProvider: LinkedIn = new LinkedIn({
    clientId: "XXXX",
    appScope: ["r_fullprofile"],
  });

and this is how I used it:

    this.cordovaOauth.logInVia(this.linkedinProvider).then(success => {
            console.log("RESULT: " + JSON.stringify(success));
        }, error => {
            console.log("ERROR: ", error);
        });

I also had a question about the other parameters linkedin requires, the ones that are mentioned here in step2 : https://developer.linkedin.com/docs/oauth2

how am I going to add them and use it, the facebook example has only these params, and when I try to add any of the linkedin params I get a compilation error:

const provider = new Facebook({
    clientId: string,
    appScope?: string[],
    redirectUri?: string,
    responseType?: string,
    authType?: string
});

iOS 10 - Google Login 403 Error: disallowed_useragent

Hello all,

I started getting an error when trying to do the Google Login on my app.
As son as the webview opens I got a 403 Error (google error):

This user-agent is not permitted to make OAuth authorisation request to Google as it is classified as an embedde user-agent (also known as a web-view). Per our policy, only browser are permitted to make authorisation request to Google. We offer several libraries and samples for native apps to perform authorisation request in browser. and i followed the same procedure which is mentioned in this link https://developers.google.com/google-apps/calendar/quickstart/ios.

Any hint on this?
Thanks in advance

New event listener for connectivity timeout

thank you for this library!!!

I insert a new reject on page load fail during internet inactivity. I hope can be useful!

provider.js => line 48

===>
browserRef.addEventListener('loaderror', function (event) {
browserRef.removeEventListener('exit', exitListener);
browserRef.close();
reject('Error load Login page');
});

Use it with google

Hi, I try to use it with google OAuth:

  1. I have activated Google+ API on https://console.developers.google.com/apis/credentials
  2. I have created an ID client OAuth

screen shot 2016-11-24 at 20 15 57

  1. I have installed ng2-cordova-oauth in my ionic2 app
  2. I have configure my app

screen shot 2016-11-24 at 20 18 09

  1. I have added a button to launch auth process

screen shot 2016-11-24 at 20 19 52

  1. I have started my app -> ionic emulate ios

  2. I have an error on IOS 10

screen shot 2016-11-24 at 20 11 40

  1. on android

screen shot 2016-11-28 at 08 55 45

Can you help me ?

Thx

Facebook auto login not closing browser

Hi,

Facebook changed a little bit a way how he handles logins from other apps, and now users can enable one click login in Safari from native app, is there a way to use Safari in place of inbrowser plugin? That way users can just login with existing info saved in Safari and avoid entering their data again.

This is one app that uses that and this is how it looks like, any way we can manage that with this plugin?

photo 9-13-16 09 58 43

thanks

Cannot read property 'split' of undefined

Hi,

I'm using your plugin with the latest version of Angular 2.

Often I can't login via Facebook because Angular 2 removes the fragment after the login. What is the best way to solve the problem?

Thanks! =)

App touch broken after oauth

the oauth works fine, it returns the user but sometimes after the in app browser close the app stop responding to screen touch, i mean, it's imposible to touch any element again, then i must close the app and reopen it ...

my code is

private oauth: OauthCordova = new OauthCordova();

  private googleProvider: Google = new Google({
    clientId: 'xxxx',
    appScope: ['email']
  })

this.oauth.logInVia(this.googleProvider).then(success => {
      if(success['access_token']){
           goHome(success)
      }
    }, error => {
      console.log("ERROR: Google", error);
    });
Your system information:

Cordova CLI: 7.0.0 
Ionic Framework Version: 2.1.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.3
ios-deploy version: Not installed
ios-sim version: 4.1.1 
OS: macOS Sierra
Node Version: v6.9.2
Xcode version: Xcode 8.3.2 Build version 8E2002

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.