Phonegap

Sample Project

Download this sample project configured with your Auth0 API Keys.

System Requirements
  • NodeJS 4.3
  • Phonegap 5.5
Show requirements

1. Setting up the callback URL in Auth0

Go to the Application Settings section in the Auth0 dashboard and make sure that Allowed Callback URLs contains the following value:

https://YOUR_AUTH0_DOMAIN/mobile

Also, if you are testing your application locally, make sure to add your local URL as an Allowed Callback URL and the following as an Allowed Origin (CORS):

file://\*

2. Add InAppBrowser plugin

You must install the InAppBrowser plugin to be able to show the Login popup. For that, just run the following command:

phonegap plugin add cordova-plugin-inappbrowser

Note: If you're using Phonegap Build service, you need to add the plugin using the <plugin name="cordova-plugin-inappbrowser" /> tag between the <widget> tags inside your config.xml file. Please check this phonegap guide for more information

3. Follow the guide specific to the FrontEnd technology you're using

Now, you can just follow the tutorial for the FrontEnd technology that you're using. We currently support applications using jQuery, AngularJS and Vanilla JS.

Warning: Phonegap doesn't support getting dependencies from a CDN, so you're going to have to download the JS and CSS dependencies locally and then point to the downloaded files.

Warning: You must use popup mode when configuring an application with Phonegap. (All available guides currently do that by default)

4. Sit back and relax

Now it's time to sit back, relax and open a beer. You've implemented Login and Signup with Auth0 and Phonegap.

Troubleshooting

Command failed with exit code 65 when running Phonegap build

This means that the InAppBrowser plugin wasn't installed successfully. Try any of the followings to fix this.

  • Reinstall the InAppBrowser plugin
phonegap plugin remove cordova-plugin-inappbrowser
phonegap plugin add cordova-plugin-inappbrowser
  • Remove the platform and re add it

iOS:

phonegap platform remove ios
phonegap platform add ios

Android:

phonegap platform remove android
phonegap platform add android
  • Copy the contents from the plugin to the platform plugins

iOS:

cp plugins/cordova-plugin-inappbrowser/src/ios/* platforms/ios/[yourAppName]/Plugins/cordova-plugin-inappbrowser/

Android:

cp plugins/cordova-plugin-inappbrowser/src/android/* platforms/android/[yourAppName]/Plugins/cordova-plugin-inappbrowser/

Get a blank page with an OK after signin

This could mean that the InAppBrowser plugin wasn't installed successfully.

Get error We could not reach the server. Please try again

This means you need to install cordova-plugin-whitelist by running following command:

ionic plugin add cordova-plugin-whitelist

After that configure your config.xml by adding or overriding following instructions:

<allow-navigation href="*.auth0.com" />
<access origin="*.auth0.com" />
Use Auth0 for FREECreate free Account