Git Product home page Git Product logo

auth0-ionic2-samples's Introduction

Auth0 - Ionic 2

This repo contains samples that demonstrate how to use Auth0 in an Ionic 2 application.

Read the quickstart guide for more detail.

What is Auth0?

Auth0 helps you to:

  • Add authentication with multiple authentication sources, either social like Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, among others, or enterprise identity systems like Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider.
  • Add authentication through more traditional username/password databases.
  • Add support for linking different user accounts with the same user.
  • Support for generating signed JSON Web Tokens to call your APIs and flow the user identity securely.
  • Analytics of how, when and where users are logging in.
  • Pull data from other sources and add it to the user profile, through JavaScript rules.

Create a free account in Auth0

  1. Go to Auth0 and click Sign Up.
  2. Use Google, GitHub or Microsoft Account to login.

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.

Author

Auth0

License

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

auth0-ionic2-samples's People

Contributors

aaguiarz avatar chenkie avatar hzalaz avatar iannyanes avatar khocef avatar mehreencs87 avatar seiyria 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

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

auth0-ionic2-samples's Issues

Using @types

I'm really excited to use Auth0 in my ionic application, but it seems that this example is quite up to date. I don't think adding scripts to index.html is a valid approach.

What I'm trying to do is to get it working with DI. I have:

  1. installed auth0, auth0-lock, @types/auth0 and @types/auth0-lock modules
  2. import Auth0 from 'auth0'; and import Auth0Lock from 'auth0-lock'; in my user-session.ts provider and provide it in the app module via providers.
  3. I'm trying to inject it in the constructor, like
constructor(auth0: Auth0, lock: Auth0Lock) {}

Now I'm stuck. I'm unable to figure out how to initialise Auth0 and pass Auth0ClientOptions (http://definitelytyped.org/docs/auth0--auth0/interfaces/auth0clientoptions.html). This method gives me Cannot find name 'Auth0'. When I try to instantiate it in the injectable class

auth0 = new Auth0(this.auth0ClientOptions);

but then it's Cannot use 'new' with an expression whose type lacks a call or construct signature.

Could you update the example to use Dependency Injections and/or properly use typed libraries?

outdated dependencies

(AUTH-3931)
Dependencies like angular/common, angular/compiler, angular/compiler-cli etc (including auth0.js and auth0-lock) are outdated.

Getting Error "Response state does not match expected state"

I have downoaded fresh demo from github repo. I using passwordless hosted page with ionic 3. I am getting below error after successfully login

Error: "Response state does not match expected state."

Please give your Help/suggestion for the same.

Skip auth0 login page

Hello,
I am implementing auth0 login with adfs on ionic 2 application. How do i skip the auth0 login page and just go straight to the adfs login page. Right now i have to enter the domain name first before i can see the adfs login page

outdated dependencies

Sample using outdated dependencies. (auth0-js and auth0-lock also outdated). (AUTH-3704)

cannot use Auth0 social connectors with ionic 2

I there,
I downloaded your ionic sample. It works great on desktop browser. But I found after trying to run on either real device (my android), or emulator GenyMotion, or Ionic View it fails.

Im running an Android Samsung Note 2

Bascially, Auth0 for Ionic 2 for android fails.

What happens when you try to use social connector (live.com ) for instance on a phone, is you get redirected via phones browser to login page, you can login successfully, and page says 'Ok',

BUT..... it does not close and redirect back to the Ionic app. The App just sits there in a frozen state doing nothing because I suppose it is expecting a code to be delivered back to it, so it can say "happy days", you are now authenticated. But this does not happen

Can you please test your ionic 2 sample on an actual Android, or use an emulator, or Ionic View to see what I mean, and confirm that your sample works, and its not just me. I have tested against emulator running Samsung Galaxy S5 as well.

Cheers

improvements to readme.md

(AUTH-4112)
In readme.md there is somebody's auth0 domain as example, but if you'll replace it with {DOMAIN} it will automatically insert user's domain.
Also, readme.md tells me to edit src/auth0-variables but this file doesnot exists.
image
image

Feature request: Add refresh token example

It would be great to have the recommended method for the refresh token in the sample code. The online docs aren't exactly clear on what is best practice for an Ionic 2 App.

Issue with signup

Hey, we've been working on an Ionic 2 app for the last couple of months and we handle authentication across our web and backend using Auth0. Everything works fine, apart from the email sign-up workflow that has an annoying issue.

When the user signs up for a fresh account, their account is registered, their profile is retrieved and token storage works correctly, but they get an InAppBrowser tab with about:blank as the location. Once the user clicks on the done button to close the InAppBrowser, the workflow behaves as expected.

I've found a very similar issue but unfortunately, it did not work for us: https://github.com/auth0/auth0-ionic/issues/17

I should mention that we're using:

  • auth0-js: 7.6.1
  • auth0-lock: 10.8.1
  • Cordova CLI: 6.5.0
  • Ionic Framework Version: 2.1.0
  • Ionic CLI Version: 2.2.1
  • Ionic App Lib Version: 2.2.0
  • Ionic App Scripts Version: 0.0.45
  • ios-deploy version: 1.9.0
  • ios-sim version: 5.0.13
  • OS: macOS Sierra
  • Node Version: v6.7.0
  • Xcode version: Xcode 8.2.1 Build version 8C1002

I should also mention that newer lock versions cause the sign-up flow to stop working altogether.

Have you encountered this before and do you know of any solutions?

Runtime Error After Login

I cloned down the repo and am able to successfully login via Auth0. However, after I login I receive a runtime error.

Runtime Error
Ionic Framework: 3.1.1
Ionic App Scripts: 1.3.12
Angular Core: 4.0.2
Angular Compiler CLI: 4.0.2
Node: 6.9.3
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36

outdated dependencies

(AUTH-4188)
Sample using outdated version of dependencies such as @angular/common, @auth0/cordova, auth0-js and others.

I can not get this sample to work with android emulator/device

As a start point I've got this sample application.

I made steps from tutorial. I can login with ios, login page opens and everything work as expected.
But I could not make login page opened on android emulator and device (both).
In Chrome Inspector (android emulator) I see this error

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'open' of undefined
TypeError: Cannot read property 'open' of undefined
at WebView.open (file:///android_asset/www/build/main.js:116941:20)
at file:///android_asset/www/build/main.js:65196:11
at file:///android_asset/www/build/main.js:116917:12
at Object.cordova.callbackFromNative (file:///android_asset/www/cordova.js:293:58)

image

Then after long 'googling' I decided to install cordova-plugin-inappbrowser, that led to page opens. But I cant login with google because of restrictions of in-app browsers. And because of this auth0 ionic2 sample application doesn't work on android.

Don't know how to solve this...
Maybe someone can help? Could someone check this sample on android device and/or update documentation if something was missed?

getDelegationToken in v7 but not in v8

This sample works perfectly, using auth0-cordova instead of auth0-lock which had many issues in Ionic. However I am struggling with my next step which is authenticating with Firebase using getDelegationToken as this function is no longer available.

Please can someone advise on an alternative method of how this can be achieved.

Thanks,

Paddy

logout & login again fails and get empty/hided browser

hi,

Great work and it works with lazy loading etc
But I have some issues when I log out and try to log in again.

On IOS I get a browser windows with no url and on android I get the front screen again. I cannot log in again. I have the reset the data on android & ios emulate.

I don't know if this is a problem with this example or with Auth0Cordova

Also I have to import Auth0Cordova and Auth0 like this else they are not imported or load them in the index.html from cdn

import * as Auth0Cordova from '@auth0/cordova';
import * as Auth0 from 'auth0-js';

Thanks Edwin

Error after following the quickstart

Hello Gentlemen!
I'm experiencing the following error after following the quickstart guide exactly.
I have built an android version and when i click the "Login" Button in the Emulator i get:

08-04 07:15:33.267 2878-2878/at.blackcloud.bloodtinnr W/zygote: Attempt to remove non-JNI local reference, dumping thread
08-04 07:15:33.343 2878-2878/at.blackcloud.bloodtinnr D/SystemWebChromeClient: file:///android_asset/www/build/main.js: Line 127 : Starting login flow...
08-04 07:15:33.343 2878-2878/at.blackcloud.bloodtinnr I/chromium: [INFO:CONSOLE(127)] "Starting login flow...", source: file:///android_asset/www/build/main.js (127)
08-04 07:15:33.345 2878-2878/at.blackcloud.bloodtinnr D/SystemWebChromeClient: ng:///AppModule/HomePage.ngfactory.js: Line 134 : ERROR
08-04 07:15:33.345 2878-2878/at.blackcloud.bloodtinnr I/chromium: [INFO:CONSOLE(134)] "ERROR", source: ng:///AppModule/HomePage.ngfactory.js (134)
08-04 07:15:33.346 2878-2878/at.blackcloud.bloodtinnr D/SystemWebChromeClient: ng:///AppModule/HomePage.ngfactory.js: Line 134 : ERROR CONTEXT
08-04 07:15:33.346 2878-2878/at.blackcloud.bloodtinnr I/chromium: [INFO:CONSOLE(134)] "ERROR CONTEXT", source: ng:///AppModule/HomePage.ngfactory.js (134)
08-04 07:15:33.348 2878-2878/at.blackcloud.bloodtinnr W/cr_Ime: updateState: type [0->0], flags [0], show [false], 
08-04 07:15:33.387 2878-2878/at.blackcloud.bloodtinnr W/zygote: Attempt to remove non-JNI local reference, dumping thread
08-04 07:15:33.456 2878-2878/at.blackcloud.bloodtinnr I/chatty: uid=10082(u0_a82) at.blackcloud.bloodtinnr identical 2 lines
08-04 07:15:33.487 2878-2878/at.blackcloud.bloodtinnr W/zygote: Attempt to remove non-JNI local reference, dumping thread
08-04 07:15:33.544 2878-2889/at.blackcloud.bloodtinnr I/zygote: NativeAllocBackground concurrent copying GC freed 9(48KB) AllocSpace objects, 0(0B) LOS objects, 66% free, 763KB/2MB, paused 11.058ms total 20.145ms
08-04 07:15:33.548 2878-2878/at.blackcloud.bloodtinnr W/zygote: Attempt to remove non-JNI local reference, dumping thread
08-04 07:15:33.801 2878-2878/at.blackcloud.bloodtinnr I/chatty: uid=10082(u0_a82) at.blackcloud.bloodtinnr identical 9 lines
08-04 07:15:33.836 2878-2878/at.blackcloud.bloodtinnr W/zygote: Attempt to remove non-JNI local reference, dumping thread
08-04 07:15:33.853 2878-2883/at.blackcloud.bloodtinnr I/zygote: Do partial code cache collection, code=54KB, data=61KB
08-04 07:15:33.853 2878-2883/at.blackcloud.bloodtinnr I/zygote: After code cache collection, code=54KB, data=61KB
08-04 07:15:33.853 2878-2883/at.blackcloud.bloodtinnr I/zygote: Increasing code cache capacity to 256KB

On the device screen just nothing happens.
Info about my Ionic version is below:

cli packages: (C:\Users\Obermoser\Desktop\bloodTin

    @ionic/cli-plugin-cordova       : 1.6.2
    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

global packages:

    Cordova CLI : 6.5.0

local packages:

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

System:

    Android SDK Tools : 25.2.5
    Node              : v8.1.3
    OS                : Windows 10
    npm               : 5.2.0

any help is appreciated

Angular 4 compatibility issue

package.json:

"dependencies": {
    "@angular/common": "4.0.2",
    "@angular/compiler": "4.0.2",
    "@angular/compiler-cli": "4.0.2",
    "@angular/core": "4.0.2",
    "@angular/forms": "4.0.2",
    "@angular/http": "4.0.2",
    "@angular/platform-browser": "4.0.2",
    "@angular/platform-browser-dynamic": "4.0.2",
    "@ionic-native/core": "3.4.2",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/status-bar": "3.4.2",
    "@ionic/storage": "2.0.1",
    "angular2-jwt": "0.1.27",
    "auth0-js": "7.4.0",
    "auth0-lock": "10.13.0",
    "ionic-angular": "3.1.1",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.5"
  },

Throws the following error for the above setup:
Uncaught Error: Cannot find module "auth0-js/plugins/cordova"

Tried upgrading auth0-js to the latest version, but ended up in further errors such as auth0_js___default.a is not a constructor

What versions should I use for auth0-js, auth0-lock and angular2-jwt to work properly?

Cannot read property 'open' of undefined

When running the example project nothing happens when I click the button and I get the following debug output:

07-07 15:26:15.443  3771  3771 D SystemWebChromeClient: file:///android_asset/www/cordova.js: Line 312 : Error in Success call backId: SafariViewController770851044 : TypeError: Cannot read property 'open' of undefined
07-07 15:26:15.443  3771  3771 I chromium: [INFO:CONSOLE(312)] "Error in Success callbackId: SafariViewController770851044 : TypeError: Cannot read property 'open' of undefined", source: file:///android_asset/www/cordova.js (312)
07-07 15:26:15.448  3771  3771 D SystemWebChromeClient: file:///android_asset/www/build/main.js: Line 1362 : ERROR
07-07 15:26:15.448  3771  3771 I chromium: [INFO:CONSOLE(1362)] "ERROR", source: file:///android_asset/www/build/main.js (1362)

Ionic-CLI: v3.4.0
Ionic: v3.5.0
Cordova: v7.0.1

EDIT: It works when I run it on my phone, but does not work in the emulator.

Customize lock shown

Hello,

How do you customize the lock shown after clicking on the login button ?
I want to add some styles and properties to the lock.

Thanks by you advance

An error ocurred when fetching data

I have cloned this repo make npm install. Deploy on android device and it causes an error
EXCEPTION: Error: An error ocurred when fetching data. main.js:42762
ORIGINAL STACKTRACE: main.js:42767
Error: Error: An error ocurred when fetching data.
at file:///android_asset/www/build/main.js:2:6812
at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:14029)
at Object.inner.inner.fork.onInvokeTask (file:///android_asset/www/build/main.js:44:21430)
at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:13965)
at e.runTask (file:///android_asset/www/build/polyfills.js:3:11389)
at invoke (file:///android_asset/www/build/polyfills.js:3:15142) main.js:42768
Uncaught Error: Error: An error ocurred when fetching data.

expires_at not equal with id_token.exp

From this sample you have an expires_at variable, and that has not the same value with the exp property from id_token jwt. This causes problems for me because the user is still logged in, but i cant do request to the api beacuse the id_token is not valid anymore.

Is it me that has misunderstood something or is this an issue?

runtime error: user canceled

screen shot 2017-07-10 at 3 22 18 pm

I'm getting a user canceled error upon clicking "Done" on the top left of the screen.

Is there a solution for this?

Changes required when updating to the ionic2 final release

Thanks for the sample application etc. I've been updating it from the release candidate to the final release. A number of changes have resulted from the upgrade to angular 2.2.1. I've tried to tackle the differences but there a couple of questions remaining. I have a working update in my fork but there is a hack in there.

  1. I generated a new tabs ionic2 template app

  2. In auth.service.ts, I had to change the line:

auth0 = new Auth0({clientID: Auth0Vars.AUTH0_CLIENT_ID, domain: Auth0Vars.AUTH0_DOMAIN });

to:

auth0 = new Auth0.WebAuth({clientID: Auth0Vars.AUTH0_CLIENT_ID, domain: Auth0Vars.AUTH0_DOMAIN });

Prior to this change I was getting the Auth0__default.a is not a constructor problem.

Once this was updated, the rest was fairly simple but I started receiving an error about the device id not being provided in options which was preventing login.

  1. I installed [email protected]
  2. I renamed main.dev.ts to main.ts as per new convention from ionic
  3. I added a auth.params.device value to fix an error from the login request. This is not recommended so needs review.

I have uploaded my version to my fork if you want to look at the diffs

infinite loading

I've triple checked the customurlscheme setup and settings in the tutorial and github, and still can't manage to get the login screen to redirect back to the app using this codebase.

Details:

  • I can see the user has logged on successfully in the auth0 console
  • using ionic devapp and with android adb logcat I see " "Navigation is unreachable: io.ionic.starter://..."
  • using ionic devapp with iphone the web view says "safari cannot open the page because the address is invalid"

I have added AndroidLaunchMode singleTask

One thing that is not clear in the tutorial, is if while adding the customurlscheme cordova plugin, if curly braces are required or not around the package ID: URL_SCHEME={YOUR_PACKAGE_ID}

I tried both (with and without curly braces) to no avail.

When would the next sample be coming out, and is there an ionic example that shows login without using the webview? I'd really like to use Auth0 for our ionic app, but the sample code is a bit rocky at the moment :) Thanks!

Lock not shown after logout

When i hit the logout button, the user logs out, but when i try to login again, i would like the lock to be shown first , not to directly logg in with the last logged in user.
When i manually go and clean history on Chrome (Android), and then try to login on my app again, then it shows up the lock.
This may not be an issue, but maybe someone can help me how to achieve what i want?

The redirect_uri parameter is not valid

Receiving this error in Auth0 log after following your guide. Any suggestions?

The redirect_uri parameter is not valid: "zendoks.app.mobile%3A%2F%2Fzendoks.auth0.com%2Fcordova%2Fzendoks.app.mobile%2Fcallback" If url looks fine, check that you are not including non printable chars

Incompatible with browser running

As widely acknowledged, the sample app won't run in browser or under ionic serve.

Obviously one of the major strengths of Ionic is the 'write once deploy anywhere concept'.

Any chance you could publish a sample app that is also compatible with browser/web running, e.g. one that switches to a non PKCE auth method when operating in browser?

Can't log in "something went wrong" message

I'm receiving this message "we're sorry, something went wrong when attempting to log in", even if I sign up with email/password, the weird thing is that in the admin page the user is registered and says that it was logged in.

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.