source code for http://ionicframework.com/blog/oauth-ionic-ngcordova/