This example will demonstrate how to use ngCordova to authenticate with various oauth providers and retrieve an access token for use with their API.
- Apache Cordova 3.5+
- Apache Cordova Whitelist Plugin
- Apache Cordova InAppBrowser Plugin
- Apache Cordova Keyboard Plugin
- Apache Cordova Statusbar Plugin
Run the following to install all necessary platforms and plugins:
ionic state reset
Download this example project from GitHub and run the following commands:
$ ionic platform add android
$ cordova plugin add org.apache.cordova.inappbrowser
$ cordova plugin add cordova-plugin-whitelist
$ cordova plugin add cordova-plugin-keyboard
$ cordova plugin add cordova-plugin-statusbar
The above commands will add the Android build platform and install the required Apache InAppBrowser plugin.
This example application requires you to have your own provider application registered with whatever provider you choose to use. Doing so will give you a unique client id that can be included into your project. When registering your application with an oauth provider, make sure to set the callback uri to http://localhost/callback, otherwise ngCordova will not function.
With the client id and information in hand, open www/js/app.js and add where appropriate.
With this example project configured on your computer, run the following from the Terminal or command prompt:
$ ionic build android
Install the application binary to your device or simulator.
Tweet me on Twitter - @nraboy
Ionic Framework - http://www.ionicframework.com
AngularJS - http://www.angularjs.org
Apache Cordova - http://cordova.apache.org
ngCordova - http://www.ngcordova.com
The Polyglot Developer - https://www.thepolyglotdeveloper.com