Giter VIP home page Giter VIP logo

auth0-cordova's Introduction

Auth0 Cordova

FOSSA Status

Warning This library has been deprecated, and official support will end on October 31, 2023. See the Migration Guide for information to migrate your application to one of our other libraries.

Library to make it easy to integrate Auth0 login in your Cordova applications.

Requirements

The library requires these two cordova plugins to work:

  • cordova-plugin-safariviewcontroller: Shows Safari/Chrome browser ViewController/CustomTab
  • cordova-plugin-customurlscheme: Handles the custom scheme url intents for callback

you'll need to run

cordova plugin add cordova-plugin-safariviewcontroller
cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME={application package name} --variable ANDROID_SCHEME={application package name} --variable ANDROID_HOST={auth0 domain} --variable ANDROID_PATHPREFIX=/cordova/{application package name}/callback

In cordova applications, the application package name is the widget's identifier in config.xml

So if you have the following values

  • application package name or widget identifier: com.auth0.cordova.example
  • auth0 domain: samples.auth0.com

in your config you should have some entries like

<preference name="AndroidLaunchMode" value="singleTask" />
<plugin name="cordova-plugin-customurlscheme" spec="~4.2.0">
    <variable name="URL_SCHEME" value="com.auth0.cordova.example" />
    <variable name="ANDROID_SCHEME" value="com.auth0.cordova.example" />
    <variable name="ANDROID_HOST" value="sample.auth0.com" />
    <variable name="ANDROID_PATHPREFIX" value="/cordova/com.auth0.cordova.example/callback" />
</plugin>
<plugin name="cordova-plugin-safariviewcontroller" spec="~1.4.6" />

Setup

From npm

npm install @auth0/cordova

then in your index.js you need to register the url handler ondeviceready

var Auth0Cordova = require('@auth0/cordova');

function main() {
    function handlerUrl(url) {
        Auth0Cordova.onRedirectUri(url);
    }
    window.handleOpenURL = handlerUrl;
    // init your application
}

document.addEventListener('deviceready', main);

Usage

const auth0 = new Auth0Cordova({
  domain: "{YOUR_AUTH0_DOMAIN}",
  clientId: "{YOUR_AUTH0_CLIENT_ID}",
  packageIdentifier: "{WIDGET_ID_IN_CONFIG_XML}"
});

const options = {
  scope: 'openid profile',
};

auth0.authorize(options, function (err, result) {
  if (err) {
    // failure
  }
  // success!
});

This will open your tenant's hosted login page in the OS browser and will use OAuth 2.0 code grant flow with Proof Key for Code Exchange.

API

For more information about our API please check our online documentation

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

For auth0 related questions/support please use the Support Center.

Common Issues

  1. The plugin is not working in Ionic / Cordova dev app.

    The plugin needs to be deployed on a real device to function, this is so because the dev apps do not add the necessary plugins needed for this library to function correctly. You'll need to either create a clone / fork of the Dev App or need to deploy it to a real device to test.

  2. The app hangs after authentication

    If 1 does not solve your problem, please make sure you have cordova-plugin-customurlscheme installed or an appropirate plugin to handle the callback (like deeplinks / universal links) and you are handling the callback appropriately

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

FOSSA Status

auth0-cordova's People

Contributors

aaguiarz avatar annyv2 avatar chenkie avatar cocojoe avatar damieng avatar darkyen avatar decates avatar dependabot[bot] avatar evansims avatar fossabot avatar hzalaz avatar jimmyjames avatar johnmclear avatar joshcanhelp avatar lbalmaceda avatar luisrudge avatar lzychowski avatar mehreencs87 avatar mgonto avatar mpaktiti avatar ntotten avatar siacomuzzi avatar snyk-bot avatar sre-57-opslevel[bot] avatar vmartynets avatar widcket 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

Watchers

 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

auth0-cordova's Issues

[android] Using --livereload with ionic renders error

I've noticed that when I run the app on my device with --livereload I'm getting this:

Error: Uncaught (in promise): TypeError: Cannot read property 'isAvailable' of undefined
TypeError: Cannot read property 'isAvailable' of undefined
    at Function.Browser.isAvailable (http://192.168.43.232:8100/build/vendor.js:194714:31)
    at getAgent (http://192.168.43.232:8100/build/vendor.js:194693:23)
    at CordovaAuth.authorize (http://192.168.43.232:8100/build/vendor.js:110120:3)
    at http://192.168.43.232:8100/build/main.js:726:20
    at new t (http://192.168.43.232:8100/build/polyfills.js:3:21506)
    at AuthService.webpackJsonp.42.AuthService.login (http://192.168.43.232:8100/build/main.js:720:16)
    at IntroPage.webpackJsonp.465.IntroPage.login (http://192.168.43.232:8100/build/main.js:1544:19)
    at Object.eval [as handleEvent] (ng:///AppModule/IntroPage.ngfactory.js:68:31)
    at Object.handleEvent (http://192.168.43.232:8100/build/vendor.js:13912:155)
    at Object.handleEvent (http://192.168.43.232:8100/build/vendor.js:14644:29)
  at Function.Browser.isAvailable (/vendor.js:194714:31)
  at getAgent (/vendor.js:194693:23)
  at CordovaAuth.authorize (/vendor.js:110120:3)
  at None (/main.js:726:20)
  at new t (/polyfills.js:3:21506)
...
(14 additional frame(s) were not displayed)

Here's a snippet of my config.xml:

    <plugin name="cordova-plugin-safariviewcontroller" spec="^1.5.2" />
    <plugin name="cordova-plugin-inappbrowser" spec="^2.0.1" />
    <plugin name="cordova-plugin-customurlscheme" spec="~4.3.0">
        <variable name="URL_SCHEME" value="*masked*.app.mobile" />
        <variable name="ANDROID_SCHEME" value="*masked*.app.mobile" />
        <variable name="ANDROID_HOST" value="*masked*.auth0.com" />
        <variable name="ANDROID_PATHPREFIX" value="/cordova/*masked*.app.mobile/callback" />
    </plugin>

Device: Samsung Galaxy S8

It would help immensely if I'd be able to develop with --livereload on my device.

auth0 cordova does not work on android4.4

Error in Success callbackId: SafariViewController1217950742 : TypeError: Object function Object() { [native code] } has no method 'assign'

Can you please document the versions for android this is supposed to support.

How to access user metadata?

As per the title, I'm not seeing any method in the client or any obvious way to easily set and retrieve metadata for a given app/user.

It's probably super obvious so sorry if I'm missing something that's in the docs -__-

Doesn't work with Ionic 1

Hi, We followed these steps for ionic 1 and it doesn't work. can you please let us know the workaround for ionic 1 asap please? We are at production and are not able to get Google to work.

The error message we get is "undefined" when we try this fix.

Please help asap - drop me a note at [email protected] if you need more information.

Missing Instruction

Cordova's phonegap-basic-sample is missing an instruction in the readme. tell the user to run cordova platform add

Cannot resolve '@auth0/cordova' in example

Running npm run build fails with error message that @auth0/cordova is missing.
Should be linked to the root of this repository or included in package.json

npm run build

> [email protected] build /home/lex/workspace/auth0-cordova/example/cordova
> webpack -p --config webpack.config.js

Hash: 80c742d5adba86a9d51b
Version: webpack 1.15.0
Time: 2829ms
       Asset     Size  Chunks             Chunk Names
    index.js  99.2 kB       0  [emitted]  main
index.js.map   692 kB       0  [emitted]  main
   [0] ./src/index.js 398 bytes {0} [built] [1 error]
  [21] ./env.js 168 bytes {0} [built]
  [62] ./src/App.js 4.02 kB {0} [built] [1 error]
    + 60 hidden modules

WARNING in index.js from UglifyJs
Condition always true [./~/auth0-js/~/url-join/lib/url-join.js:3,0]
Dropping unreachable code [./~/auth0-js/~/url-join/lib/url-join.js:4,0]
Side effects in initialization of unused variable loc [./~/auth0-js/~/winchan/winchan.js:70,0]
Condition always true [./~/auth0-js/~/idtoken-verifier/~/crypto-js/core.js:2,0]
Dropping unreachable code [./~/auth0-js/~/idtoken-verifier/~/crypto-js/core.js:6,0]
Side effects in initialization of unused variable Hasher [./~/auth0-js/~/idtoken-verifier/~/crypto-js/core.js:621,0]
Condition always true [./~/auth0-js/~/idtoken-verifier/~/crypto-js/sha256.js:2,0]
Dropping unreachable code [./~/auth0-js/~/idtoken-verifier/~/crypto-js/sha256.js:6,0]
Condition always true [./~/auth0-js/~/idtoken-verifier/~/jsbn/index.js:1350,0]
Dropping unreachable code [./~/auth0-js/~/idtoken-verifier/~/jsbn/index.js:1353,0]
Condition always true [./~/auth0-js/~/superagent/~/component-emitter/index.js:6,0]
Dropping unused function getAllBySelector [./src/App.js:6,0]
Dropping unused function getAllByClassName [./src/App.js:18,0]
Side effects in initialization of unused variable decodeJwt [./src/App.js:3,0]

ERROR in ./src/index.js
Module not found: Error: Cannot resolve module '@auth0/cordova' in /home/lex/workspace/auth0-cordova/example/cordova/src
 @ ./src/index.js 1:20-45

ERROR in ./src/App.js
Module not found: Error: Cannot resolve module '@auth0/cordova' in /home/lex/workspace/auth0-cordova/example/cordova/src
 @ ./src/App.js 4:20-45

issues with testing it on the new ionic 2 example

hi,

I was testing the new ionic 2 example https://github.com/auth0-samples/auth0-ionic2-samples and it works on android and ios with the google authentication.

But when I logout and do a login again it will open a window again on IOS but in this case the url is empty and can only press done.
Do the same on android it closes everything and need to open the app again without being authenticated.
I only get it working with android or IOS emulate when I wipe all the data.

When you look at the provider code, it is not much I can do.
https://github.com/auth0-samples/auth0-ionic2-samples/blob/master/01-Login/src/services/auth.service.ts#L55

Is this is auth0-cordova issue and do I need to cleanup something when I do logout.

thanks Edwin and keep up the great work.

Native Google login

Currently this always uses the in-app browser for login, which means if the user is already logged in via their Android device they will have to login again. This is ugly and not ideal since other apps will just get asked to use the account they already logged in with.

@auth0/cordova npm package no longer registered

It seems you aren't registering the @auth npm registry anymore? This was working a week ago. npm install of your package now fails. Please advise.

No registry here: https://registry.npmjs.org/auth0/cordova/0.2.0

npm install @auth0/cordova

npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/auth0/cordova/0.2.0
npm http 404 https://registry.npmjs.org/auth0/cordova/0.2.0
npm ERR! 404 'auth0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

npm ERR! System Linux 3.13.0-125-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "@auth0/cordova"
npm ERR! cwd /vagrant
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! code E404
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /vagrant/npm-debug.log
npm ERR! not ok code 0```

No logout method implementation.

Is there a reason it wasn't included? I've written an implementation using this repo's getAgent logic (< 10 lines) and would be happy to open a PR for this feature, if that sounds good to you @chenkie?

Blank page - stored credentials iOs social login

I am using this lib to add auth0 authentication (google, facebook, database) to Ionic1 application. With plugins, it now works OK on Android, but on iOS, when user has previously logged in with Gmail account, the popup is stuck on blank page, and no tokens are returned to the Ionic app.
http://i.imgur.com/lQjUI6n.png
Any idea, what I could be doing wrong?

Safari cannot open the page because the address is invalid

Hello, I have followed every steps of this tutorial: https://auth0.com/docs/quickstart/native/ionic2 . I can access the login page and I can also login successfully (logs in my client are displaying "Success Login" with the proper user) but right after, I get a "Safari cannot open the page because the address is invalid". When I open the url in safari (not in the web view in ionic), I'm getting "Oops!, something went wrong" in https://mydomain.auth0.com/login/callback .Here are some code samples I'm using:

auth.service.ts

const auth0Config = {
    // needed for auth0
    clientID: 'my client id is here',

    // needed for auth0cordova
    clientId: 'my client id is here',
    domain: 'mydomain.auth0.com',
    callbackURL: location.href,
    packageIdentifier: 'io.ionic.starter'
};

config.xml

<plugin name="cordova-plugin-customurlscheme" spec="^4.3.0">
        <variable name="URL_SCHEME" value="io.ionic.starter" />
        <variable name="ANDROID_SCHEME" value="io.ionic.starter" />
        <variable name="ANDROID_HOST" value="mydomain.auth0.com" />
        <variable name="ANDROID_PATHPREFIX" value="/cordova/io.ionic.starter/callback" />
    </plugin>

package.json

"cordova": {
    "plugins": {
      "cordova-plugin-safariviewcontroller": {},
      "cordova-plugin-customurlscheme": {
        "URL_SCHEME": "io.ionic.starter",
        "ANDROID_SCHEME": "io.ionic.starter",
        "ANDROID_HOST": "mydomain.auth0.com",
        "ANDROID_PATHPREFIX": "/cordova/io.ionic.starter/callback"
      },
      "ionic-plugin-keyboard": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {}
    },
    "platforms": [
      "ios"
    ]
  }

I'm using:

"@angular/common": "5.0.3",
    "@angular/compiler": "5.0.3",
    "@angular/compiler-cli": "5.0.3",
    "@angular/core": "5.0.3",
    "@angular/forms": "5.0.3",
    "@angular/http": "5.0.3",
    "@angular/platform-browser": "5.0.3",
    "@angular/platform-browser-dynamic": "5.0.3",
    "@auth0/cordova": "^0.3.0",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/pro": "1.0.16",
    "@ionic/storage": "2.1.3",
    "auth0-js": "^9.0.2",
    "cordova-ios": "4.5.4",
    "cordova-plugin-customurlscheme": "^4.3.0",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-inappbrowser": "^2.0.1",
    "cordova-plugin-ionic-webview": "^1.1.16",
    "cordova-plugin-safariviewcontroller": "~1.5.2",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-whitelist": "1.3.1",
    "ionic-angular": "3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"

My client in auth0 is configured properly:
Domain: mydomain.auth0.com
ClientType: Native
Allowed Callback URLs: io.ionic.starter://mydomain.auth0.com/cordova/io.ionic.starter/callback
Allowed Origins (CORS): file://*

Last thing, i'm trying this with Ionic DevApp for iOS

I just don't know what to do with this!

Thank you

Error in Success callbackId: SafariViewController1328020603 : TypeError: crypto.randomBytes is not a function

Hello, I've got an existing angular cli project that we're converting to a Cordova project. Right now I'm moving our authentication over from using the auth0-js lib to the auth0-cordova plugin. I'm getting this error when attempting to call .authorize() on auth0 object Error in Success callbackId: SafariViewController1328020603 : TypeError: crypto.randomBytes is not a function.

I've tried testing on an emulator device running API version 27 and 26. I've also testing on a physical device running 8.1. All the same result.

I've added the cordova-plugin-safariviewcontroller and cordova-plugin-customurlscheme plugins.

The code I'm using to create the client looks like this:

import Auth0Cordova from '@auth0/cordova';

// Class code...

public auth0Authentication = new Auth0Cordova({
    domain: AUTH_CONFIG.domain,
    clientId: AUTH_CONFIG.clientID,
    packageIdentifier: AUTH_CONFIG.packageID,
  });

// Other Code...

// Actual handler of the login button click
public login(): void {
console.log('Auth Service Login');
  const options = {
    scope: 'openid profile',
  };
  this.auth0Authentication.authorize(options, function (error, result) {
    if (error) {
      console.log(`Error with authentication: ${ JSON.stringify(error, null, 2) }`);
    }
    else {
      console.log(`Login result: ${ JSON.stringify(result, null, 2) }`);
    }
  });
}

Any help and or direction would be greatly appreciated.

Android 4.4: Object has no method 'assign'

I have tested the library on the Android 4.4 and popup for social login did not appear. The error: Uncaught TypeError: Object function Object() { [native code] } has no method 'assign'.

Examples should not include iOS platform included

The examples should be agnostic toward the Cordova platform. Since Cordova is a hybrid framework for mobile, the examples should not be biased towards iOS, ie. That way the user must add the platform they want to use in their particular scenario, and the platform dependencies will always be the latest, and the current ones compatible with the users development environment.

Android: Norton "Link Guard" issue

When an Android device has Norton Mobile Security installed, and specifically uses the "Link Guard" feature to open the Auth0 login page, I'm noticing an odd result. The login succeeds but the app remains at the login page when it redirects back to the app.

Upon digging a little bit more it looks like something is triggering a "User Canceled" error prior to getting to the Auth0 login page. However, the Auth0 login page still appears, and the login is able to succeed based on Auth0 logs. But the Auth0 Cordova authorize callback does not get called with successful login info (likely because it was already called with a "User Canceled" error?)

Is this supposed to work on windows10 with cordova?

I have not been able to get this to work with windows10, is this not supported? I am having several issues including a double loaded events within agent.open which cause the session.start to fail and the more-so, window.handleOpenURL is never called.

Update Lock and InAppBrowser

Lock should be updated to the latest 7.11.1 version, and also InAppBrowser should be updated too since now its package is named cordova-plugin-inappbrowser .

Silent authentication - checkSession

Would it be possible to do silent authentication, without opening the browser window? Basically, what auth0-js checkSession does.
Right now we are using normal authentication with extra "prompt=none" attribute. This works, but It still opens browser and then quickly closes it.

This is the recommended way of refreshing access token without keeping the refresh_token

Configuration used with auth0-lock doesn't appear to be compatible

We customize our auth0-lock instance with a custom dictionary, icons, colors, etc... I am passing in the same config to Auth0.Cordova but those customizations don't appear to be honored. The title of the lock dialog presented is the name of the auth0 client (which I consider somewhat internal)

Is this expected or just not implemented yet?

Timing has changed in authorize method, results in hung login when already logged in to IDP.

Not sure what has changed but this was working roughly a month ago.

I'm using google-oauth2 as the connection type.

When the user has already logged in once so google remembers the login the timing becomes screwed up and the onRedirectUri callback is triggered too soon.


CordovaAuth.onRedirectUri = function (url) {
  session.onRedirectUri(url);
};

The timing becomes.

CordovaAuth.prototype.Authorize ->
getAgent ->
agent.open ->
(opened event) - which is skipped via // if (result.event !== 'loaded') { return; }
onRedirectUri (has no session.start method at this point)
(loaded event) - sets the session.start method but has no redirect trigger to work upon at this time.

I have no idea what changed but this was working a month ago. By allowing the opened event to set session.start (and also removing the session.start only occuring once check) it works as it used to. please advise, this is very troubling when my implementation didn't change.

Cancel action not behaving properly on Android

Consider this scenario:

  • client.authorize(...) is called which opens a new browser window
  • Instead of logging in, the user closes the window, returning back to the app

This is handled properly on iOS, an error with message "user canceled" is thrown and the app can act accordingly. However, on Android the callback is never fired, no error is being triggered.

The browser is properly triggering a "Closed" event in src/agent/browser, but for some reason the auth0 client is only relaying the "user canceled" error for iOS:
https://github.com/auth0/auth0-cordova/blob/master/src/index.js#L96

TL;DR:
If a user on Android closes the popup browser without logging in, the app doesn't receive a callback.

Double-encoded redirect uri on ios.

In my application, I use auth0-Cordova. It was working fine until 04 of December. From that time we can't 'sign in' in the application on IOS because of the wrong URI.

So, I get 400 error
"date": "2017-12-05T15:58:02.787Z", "type": "f", "description": "The redirect_uri parameter is not valid: \"com.myDomain%3A%2F%2FmyDomain.eu.auth0.com%2Fcordova%2Fcom.myDomain%2Fcallback\" If url looks fine, check that you are not including non printable chars", "connection_id": "", "client_id": "myClientId", "ip": "userIp", "user_agent": "Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)", "details": { "body": {}, "qs": { "client_id": "clientId", "scope": "openid%20profile%20offline_access", "state": "state", "code_challenge_method": "S256", "response_type": "code", "redirect_uri": "com.myDomain%3A%2F%2FmyDomain.eu.auth0.com%2Fcordova%2Fcom.myDomain%2Fcallback", "code_challenge": "codeChallenge", "auth0Client": "authClienId%3D" }, "error": { "message": "The redirect_uri parameter is not valid: \"com.myDomain%3A%2F%2FimyDomain.eu.auth0.com%2Fcordova%2Fcom.myDomain%2Fcallback\" If url looks fine, check that you are not including non printable chars", "oauthError": "invalid_request", "type": "request-error" } }, "log_id": "49570627966157796216778371576494069746271817758977032242" }

I found that URI is double-encoded by safari view controller. I mean that first encoding of URI happens in auth0-Cordova plugin and the second happens in safari-web view.

So, as you didn't update auth0-cordova I suppose that this happens because of Auth0 API was changed. Could you approve my version?

For example:
Expected encoded string(That's how it is on Android):
%3A%2F%2

On safari web view:
%253A%252F%252 (double-encoded)

P.S: Android still works fine.

Missing instruction

Cordova's basic sample is missing an instruction in the readme. tell the user to run cordova platform add

Callback not fired in client.authorize() when connection parameter is passed

I'm trying to open Google authentication directly from my Cordova app rather than going to the hosted login page and having the user click "Sign in with Google." I'm passing the connection parameter into the client.authorize() function like so:

    let auth0Config = {
      clientId: this.config.auth0.clientId,
      domain: this.config.auth0.domain,
      callbackURL: this.config.auth0.callbackURL,
      packageIdentifier: this.config.auth0.packageIdentifier
    }
    const client = new Auth0Cordova(auth0Config)
    const options = {
      scope: 'openid profile offline_access',
      audience: this.config.auth0.audience,
      connection:'google-oauth2',
    }
    client.authorize(options, (err, authResult) => {})

It is loading the Google OAuth page as expected however once the user authenticates, the callback is not fired. The url is being redirected back to the app, and I am passing it into Auth0Cordova.onRedirectUri()

The same process works as expected without the connection parameter so I'm wondering if this library does not support a connection parameter? I know this is possible with the Auth0-js library.

Thank you

EDIT: It only occurs when I've previously logged in with Google and it remembers my login. The redirect seems to be happening too early. If it is my first time authenticating with Google it works as expected.

Can't authorize if using a proxy

When I try to login to the application using proxies, auth0 widget doesn't fetch accounts.

`
auth0Config = {
clientId: ...
clientID: ...
domain: ...
callbackURL: location.href,
packageIdentifier: ...
};

let options = {
scope: 'openid profile ',
connection: 'google-oauth2'
};

new Auth0Cordova(this.auth0Config).authorize(options, (error, authResult) => {....})

img_20171108_140825

Without proxies, all works fine and I can log in.

img_20171107_210107

Does not work with WKWebView on iOS

Using this is a recent Ionic(3+) project, I came to notice that the plugin did not route the success callback or dismiss the SafariViewController after I added the "official" Ionic WKWebView plugin. This may be due to the fact there there is a local webserver being used to serve files and the file:// protocol is "not allowed" (though I have gotten it to work on iOS 10). I would say that it might be a CORS issue, since Auth0 domains likely have restrictions.

The Auth0 console shows a successful login, but the view does not move past accounts.google.com/...

screen shot 2017-05-30 at 1 58 21 pm
img_0020

Auth0.js v9 update breaks auth0-cordova

Auth0.js v9 changed the signature of one of the APIs used by auth0-cordova.

API change:

auth0/auth0.js@06e6860#diff-757cd8fb74b000a4da9ea0fd33713c52R28

Notice the auth0 argument added in front of the options argument.

auth0-cordova uses this in: https://github.com/auth0/auth0-cordova/blob/master/src/index.js#L33

This causes the options parameter to be used in place of the new auth0 parameter, resulting in an exception in auth0.js, preventing instantiation of the Auth0Cordova object (and thus use of the library).

For example, this application has stopped working after updating the dependencies to auth0.js v9:

https://github.com/auth0-blog/ionic-got

Login not working on specific devices

I've built an Ionic 2 app that I am about to release to the Google Play Store and the App Store. Sadly I am getting reports that some users cannot log in on specific devices. Most devices do work allow logging in but some do not. It is hard to test all devices, but luckily a customer was able to lend me a device where he could not log in.

This device is a Galaxy tab and indeed the app does not allow me to log in on that device. I've tried to log in with the same app on a few of my own android/ios devices that I have lying around and on those we can log in. The login screen appears just fine on the Galaxy Tab but when I enter my credentials and press login I get an ERR_UNKNOWN_URL_SCHEME error on my callback URL. So I dove in the Auth0-Cordova plugin to see what is happening and the only difference I saw between the two devices (that work and do not work) is that the login screen gets opened a different way.

It is this piece of code that is located in @auth0/cordova/docs/src/agent/index.js of the @auth0/cordova npm package that is producing different results on the devices. Again we are still talking about the app I build.

module.exports = function getAgent(callback) {
    console.log(BrowserAgent, 'browser agent');
    return BrowserAgent.isAvailable(function (available) {
        console.log(available, 'browser agent available');
        if (available) {
            // Variable 'available' is true on the device that works
            return callback(null, new BrowserAgent());
        }
        // Variable 'available' is false on the device that does not work
        return callback(null, new WebViewAgent());
    });
};

When I use the chrome inspect feature to check to see what is going on, I see on the device that works normally that it has one view open (the login screen). But when I check the device that does not work it has two view open, the login screen has a view and the app opens in a different view. It looks to me that whenever I log in on the device that doesn't work it can not redirect back to the app after validating the credentials because they are opened in different views/screens/browser. Perhaps the issue? I don't know.

So I decided to try to reproduce it in a standalone app. I've downloaded your auth0/ionic2 example here, https://auth0.com/docs/quickstart/native/ionic2/01-login, installed the node_modules and configured the auth0 settings.

First I deployed the login example app on the device that worked with my app, the LG Android device (see specs below). I could log in on the LG without any problems. Next, I deployed the same app on the Samsung Galaxy Tab (the device that didn't allow me to log in) and on this device the login failed. Not exactly the same issue as in my own app, but it the same code base causes an issue.

I check the used agent on each device by logging it in @auth0/src/index.js.

  getAgent(function (err, agent) {
        console.log(agent, 'USED AGENT');
        if (err) {
            return callback(err);
        }

As you can see in the screenshots, you can see the working device uses the Browser as agent and the device that does not work is (trying) to use the Webview. As you can see the example app also produces the error.

cannot read property 'open' of undefined.

And from there I don't know what to do anymore. I would appreciate some help with the issue.

Devices used

  • Galaxy Tab A (2016) SM-T280 (doesn't work) Android version 5.1.1
  • LG -D722 (works) Android version 5.0.2
  • iPhone 5s (works) iOS version 11.0.3

The sample project that has been used can be found here. Note that I have removed my own auth0 configuration in the AuthService.

Related:

samsunggalaxytab

lg

idToken "invalid signature" JWT

When running authorize I have been trying to using the JWT idToken to sign into firebase by
firebase.auth().signInWithCustomToken(idToken)

However I getting a "bad request" error message. So I copied out the JWT idToken string to the debugger on https://jwt.io/ and it is showing "Invalid Signature".

Please can you confirm if there is an issue with the JWT idToken.

Multiple Calls to Auth

If a user tries to authenticate, then closes the window, and tries again, the following error results. Seems like something in the cordova authorize() method isn't happy with multiple calls?

Error in Success callbackId: SafariViewController272141010 : Error: Only one instance of auth can happen at a time

Inapp Browser error

When testing Phonegap Native, this error was encountered

Error: Cannot find plugin.xml for plugin 'org.apache.cordova.inappbrowser'. Please try adding it again

IOS: Login screen hangs after entering credentials

I've followed the basic setup instructed here. On an Android device logging in works fine, but when deploying to my iPhone 5s (iOS 11.0.3) it just keeps loading after entering my credentials and pressing 'login'.

Any idea on what the cause can be? I've used the example app provided by the above instructions. You can grab it here. Note that I have removed the used auth0 settings and app identifier (had to change it to one of my own to be able to deploy it to my iOS device.

UPDATE:

It looks like that this callback is not triggered after entering the credentials and logging in.

Ionic v2 iOS: Safari cannot open the page because the address is invalid

I'm assuming this is due to something with the custom urlscheme configuration?

I'm using the Ionic example and I've edited package.json as follows to match my widget id:

            "cordova-plugin-customurlscheme": {
                "URL_SCHEME": "com.agilitycoursemaster.ACMaster"
            },

Which generates this entry in config.xml:

    <plugin name="cordova-plugin-customurlscheme" spec="^4.2.0">
        <variable name="URL_SCHEME" value="com.agilitycoursemaster.ACMaster" />
    </plugin>

Which matches the name of my callback URL in Auth0:
com.agilitycoursemaster.ACMaster://agilitycoursemaster.auth0.com/cordova/com.agilitycoursemaster.ACMaster/callback

I've confirmed the login succeeds via the Auth0 logs.

I couldn't find any documentation on setting this up correctly.

Spins forever if there is no internet connection

Ideally if there was no internet connection, the UI would stop and show an error like "You are not conencted to the internet. Please check your connection and click here to try again: [Login]". Currently it seems to just show a spinner endlessly.

Can this be used for Ionic2 ?

I am trying to use it with Ionic2 but on pc i get Cannot read property 'isAvailable' of undefined, while on android i get a strange callback url which of course is not in the list of allowed callback url-s of my auth0 Client

We could not reach the server issue

When testing Phonegap seed project, different versions of Lock had the same issue "We could not reach the server. Please try again"

For cordova-android 4 or above cordova-plugin-whitelist needs to be added to enable and restrict network access in the application.

Auth0Cordova does not exist

I have built the repository, and importing index.js from into my application, I can get access to PKCEClient not Auth0Cordova. Some documentation on that would be very useful. I managed to open the Lock widget, but now I can't find a replacement for the Auth0Cordova.onRedirectUri that would handle the passed back result.
What is more, the auth0 popup remains open in the background on my android device, any way to close that?

Cannot make OAuth request in Android older than 6.0.0

I am trying to add Auth0 JWT authentication to Ionic Cordova app.

As i understand SafariViewController on which this plugin relies on do not work on older versions of webview, so for that reason auth0-cordova uses fallback to cordova-inappbrowser. But for now Google no longer support OAuth connection for embeeded browsers, so i get “Dissalowed user agent”.

I can put <preference name="OverrideUserAgent" value="Mozilla/5.0 Google" /> into my config.xml, which makes it work on some devices, but on other devices inappbrowser cannot handle custom uri scheme. So I cannot rely on that workaround.

Would be gratefull for any kind of help.

When user cancel the login and try again, session is not cleaned

It seems that when a user tries to login (on Android), and then cancel, the login function no longer works, it throws an exception:

vendor.js:1811 ERROR Error: Uncaught (in promise): Error: Only one instance of auth can happen at a time Error: Only one instance of auth can happen at a time at Function.Session.start (vendor.js:209530) at vendor.js:108037 at vendor.js:199909 at Object.callbackFromNative (cordova.js:293) at processMessage (cordova.js:1119) at processMessages (cordova.js:1142) at t.invoke (polyfills.js:3) at Object.onInvoke (vendor.js:5104) at t.invoke (polyfills.js:3) at r.run (polyfills.js:3) at Function.Session.start (vendor.js:209530) at vendor.js:108037 at vendor.js:199909 at Object.callbackFromNative (cordova.js:293) at processMessage (cordova.js:1119) at processMessages (cordova.js:1142) at t.invoke (polyfills.js:3) at Object.onInvoke (vendor.js:5104) at t.invoke (polyfills.js:3) at r.run (polyfills.js:3) at c (polyfills.js:3) at polyfills.js:3 at t.invokeTask (polyfills.js:3) at Object.onInvokeTask (vendor.js:5095) at t.invokeTask (polyfills.js:3) at r.runTask (polyfills.js:3) at o (polyfills.js:3)

If within the CordovaAuth.prototype.authorize I add a session.clean(), the problem goes away. There is probably a better fix. Can you look into it?

The address bar

Hi,

When I use this to authenticate, for example instragram via android, the location bar is shown, this looks pretty bad - are you able to allow the location bar to be hidden? I can see that it is an option in the plugin:

https://github.com/apache/cordova-plugin-inappbrowser

var ref = cordova.InAppBrowser.open(url, target, {
    location: "no"
});

Even adding it as an option that uses the current behaviour by default would be fine.

Edit: clarify that you can actually see the instagram bar, but it would still be nice to be able to configure it.

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.