From 4e5974e443d7f4bce8597bfb544c610dd4a69736 Mon Sep 17 00:00:00 2001
From: Himanshu_Chandra
Date: Mon, 5 Jun 2017 11:03:47 +0530
Subject: [PATCH 1/4] removed facebook and google clientside added added oauth
---
bower.json | 5 +-
config.xml | 4 +-
www/index.html | 3 +-
www/js/app.js | 17 +-
www/js/controllers/facebook.js | 96 +-
www/js/controllers/google.js | 54 +-
www/lib/angular-google-plus/.bower.json | 33 -
www/lib/angular-google-plus/CHANGELOG.md | 41 -
www/lib/angular-google-plus/Gruntfile.js | 69 -
www/lib/angular-google-plus/LICENSE | 20 -
www/lib/angular-google-plus/README.md | 53 -
www/lib/angular-google-plus/bower.json | 23 -
.../dist/angular-google-plus.js | 145 -
.../dist/angular-google-plus.min.js | 2 -
www/lib/angular-google-plus/karma.conf.js | 67 -
www/lib/angular-google-plus/package.json | 46 -
.../src/angular-google-plus.js | 184 -
www/lib/ng-cordova-oauth/.bower.json | 41 +
www/lib/ng-cordova-oauth/CHANGELOG.md | 120 +
www/lib/ng-cordova-oauth/Gruntfile.js | 52 +
.../{ng-facebook => ng-cordova-oauth}/LICENSE | 13 +-
www/lib/ng-cordova-oauth/README.md | 204 +
www/lib/ng-cordova-oauth/bower.json | 31 +
.../ng-cordova-oauth/dist/ng-cordova-oauth.js | 3363 +++++++++++++++++
.../dist/ng-cordova-oauth.min.js | 4 +
www/lib/ng-cordova-oauth/karma.conf.js | 81 +
www/lib/ng-cordova-oauth/package.json | 41 +
www/lib/ng-cordova-oauth/src/oauth.500px.js | 50 +
www/lib/ng-cordova-oauth/src/oauth.adfs.js | 56 +
www/lib/ng-cordova-oauth/src/oauth.azuread.js | 62 +
www/lib/ng-cordova-oauth/src/oauth.box.js | 63 +
.../src/oauth.digitalOcean.js | 61 +
www/lib/ng-cordova-oauth/src/oauth.dribble.js | 78 +
www/lib/ng-cordova-oauth/src/oauth.dropbox.js | 59 +
www/lib/ng-cordova-oauth/src/oauth.envato.js | 62 +
.../ng-cordova-oauth/src/oauth.facebook.js | 68 +
.../src/oauth.familySearch.js | 60 +
.../ng-cordova-oauth/src/oauth.foursquare.js | 66 +
www/lib/ng-cordova-oauth/src/oauth.github.js | 62 +
www/lib/ng-cordova-oauth/src/oauth.google.js | 26 +
www/lib/ng-cordova-oauth/src/oauth.imgur.js | 60 +
.../ng-cordova-oauth/src/oauth.instagram.js | 80 +
www/lib/ng-cordova-oauth/src/oauth.jawbone.js | 65 +
www/lib/ng-cordova-oauth/src/oauth.js | 147 +
.../ng-cordova-oauth/src/oauth.linkedin.js | 68 +
www/lib/ng-cordova-oauth/src/oauth.magento.js | 116 +
www/lib/ng-cordova-oauth/src/oauth.meetup.js | 59 +
.../src/oauth.mercadolibre.js | 59 +
www/lib/ng-cordova-oauth/src/oauth.netatmo.js | 103 +
.../src/oauth.odnoklassniki.js | 55 +
www/lib/ng-cordova-oauth/src/oauth.pocket.js | 86 +
www/lib/ng-cordova-oauth/src/oauth.rally.js | 63 +
www/lib/ng-cordova-oauth/src/oauth.reddit.js | 63 +
.../ng-cordova-oauth/src/oauth.salesforce.js | 74 +
www/lib/ng-cordova-oauth/src/oauth.slack.js | 64 +
www/lib/ng-cordova-oauth/src/oauth.spotify.js | 75 +
www/lib/ng-cordova-oauth/src/oauth.strava.js | 63 +
www/lib/ng-cordova-oauth/src/oauth.stripe.js | 63 +
www/lib/ng-cordova-oauth/src/oauth.trakttv.js | 67 +
www/lib/ng-cordova-oauth/src/oauth.twitter.js | 124 +
www/lib/ng-cordova-oauth/src/oauth.uber.js | 65 +
www/lib/ng-cordova-oauth/src/oauth.untappd.js | 65 +
www/lib/ng-cordova-oauth/src/oauth.venmo.js | 65 +
.../ng-cordova-oauth/src/oauth.vkontakte.js | 59 +
www/lib/ng-cordova-oauth/src/oauth.weibo.js | 73 +
.../ng-cordova-oauth/src/oauth.windowslive.js | 63 +
.../ng-cordova-oauth/src/oauth.withings.js | 113 +
www/lib/ng-cordova-oauth/src/oauth.xing.js | 126 +
www/lib/ng-cordova-oauth/src/oauth.yahoo.js | 79 +
www/lib/ng-cordova-oauth/src/oauth.yammer.js | 62 +
www/lib/ng-cordova-oauth/src/plugin.js | 63 +
www/lib/ng-cordova-oauth/src/utility.js | 159 +
www/lib/ng-facebook/.bower.json | 35 -
www/lib/ng-facebook/.gitignore | 59 -
www/lib/ng-facebook/.travis.yml | 22 -
www/lib/ng-facebook/README.md | 143 -
www/lib/ng-facebook/bower.json | 25 -
www/lib/ng-facebook/ngFacebook.js | 244 --
www/lib/ng-facebook/package.json | 31 -
www/lib/ng-facebook/protractor.conf.js | 24 -
.../test/features/ngFacebook.feature | 12 -
www/lib/ng-facebook/test/index.html | 40 -
www/lib/ng-facebook/test/index.js | 50 -
.../ng-facebook/test/scripts/web-server.js | 19 -
www/lib/ng-facebook/test/specs/def.js | 105 -
85 files changed, 7357 insertions(+), 1583 deletions(-)
delete mode 100644 www/lib/angular-google-plus/.bower.json
delete mode 100644 www/lib/angular-google-plus/CHANGELOG.md
delete mode 100644 www/lib/angular-google-plus/Gruntfile.js
delete mode 100644 www/lib/angular-google-plus/LICENSE
delete mode 100644 www/lib/angular-google-plus/README.md
delete mode 100644 www/lib/angular-google-plus/bower.json
delete mode 100644 www/lib/angular-google-plus/dist/angular-google-plus.js
delete mode 100644 www/lib/angular-google-plus/dist/angular-google-plus.min.js
delete mode 100644 www/lib/angular-google-plus/karma.conf.js
delete mode 100644 www/lib/angular-google-plus/package.json
delete mode 100644 www/lib/angular-google-plus/src/angular-google-plus.js
create mode 100644 www/lib/ng-cordova-oauth/.bower.json
create mode 100644 www/lib/ng-cordova-oauth/CHANGELOG.md
create mode 100644 www/lib/ng-cordova-oauth/Gruntfile.js
rename www/lib/{ng-facebook => ng-cordova-oauth}/LICENSE (87%)
create mode 100644 www/lib/ng-cordova-oauth/README.md
create mode 100644 www/lib/ng-cordova-oauth/bower.json
create mode 100644 www/lib/ng-cordova-oauth/dist/ng-cordova-oauth.js
create mode 100644 www/lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.js
create mode 100644 www/lib/ng-cordova-oauth/karma.conf.js
create mode 100644 www/lib/ng-cordova-oauth/package.json
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.500px.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.adfs.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.azuread.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.box.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.digitalOcean.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.dribble.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.dropbox.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.envato.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.facebook.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.familySearch.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.foursquare.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.github.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.google.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.imgur.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.instagram.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.jawbone.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.linkedin.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.magento.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.meetup.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.mercadolibre.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.netatmo.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.odnoklassniki.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.pocket.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.rally.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.reddit.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.salesforce.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.slack.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.spotify.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.strava.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.stripe.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.trakttv.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.twitter.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.uber.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.untappd.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.venmo.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.vkontakte.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.weibo.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.windowslive.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.withings.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.xing.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.yahoo.js
create mode 100644 www/lib/ng-cordova-oauth/src/oauth.yammer.js
create mode 100644 www/lib/ng-cordova-oauth/src/plugin.js
create mode 100644 www/lib/ng-cordova-oauth/src/utility.js
delete mode 100644 www/lib/ng-facebook/.bower.json
delete mode 100644 www/lib/ng-facebook/.gitignore
delete mode 100644 www/lib/ng-facebook/.travis.yml
delete mode 100644 www/lib/ng-facebook/README.md
delete mode 100644 www/lib/ng-facebook/bower.json
delete mode 100644 www/lib/ng-facebook/ngFacebook.js
delete mode 100644 www/lib/ng-facebook/package.json
delete mode 100644 www/lib/ng-facebook/protractor.conf.js
delete mode 100644 www/lib/ng-facebook/test/features/ngFacebook.feature
delete mode 100644 www/lib/ng-facebook/test/index.html
delete mode 100644 www/lib/ng-facebook/test/index.js
delete mode 100644 www/lib/ng-facebook/test/scripts/web-server.js
delete mode 100644 www/lib/ng-facebook/test/specs/def.js
diff --git a/bower.json b/bower.json
index bf957c1..0887afe 100644
--- a/bower.json
+++ b/bower.json
@@ -7,8 +7,7 @@
"dependencies": {
"angular-md5": "^0.1.10",
"ng-country-select": "^0.1.4",
- "ng-facebook": "^0.1.6",
- "angular-google-plus": "^0.1.3",
- "ngstorage": "^0.3.11"
+ "ngstorage": "^0.3.11",
+ "ng-cordova-oauth": "^0.3.0"
}
}
diff --git a/config.xml b/config.xml
index 16fd135..d210f60 100644
--- a/config.xml
+++ b/config.xml
@@ -4,8 +4,8 @@
An Ionic Framework and Cordova project.
-
- Your Name Here
+
+ Himanshu Chandra
diff --git a/www/index.html b/www/index.html
index 8dc1717..79d2622 100644
--- a/www/index.html
+++ b/www/index.html
@@ -30,9 +30,8 @@
-
+
-
diff --git a/www/js/app.js b/www/js/app.js
index a588cf0..281c795 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -7,10 +7,9 @@
// 'starter.controllers' is found in controllers.js
angular.module('appskeleton', [
'ionic',
+ 'ngCordovaOauth',
'angular-md5',
'countrySelect',
- 'googleplus',
- 'ngFacebook',
'ngStorage'
])
@@ -31,22 +30,14 @@ angular.module('appskeleton', [
})
.constant("requrl","http://192.168.0.102:1234")
+.constant("GOOGLE_CLIENT_ID","11067462844-4s6bjl47j6m7v2g4it1ndnfbgirk7m3g.apps.googleusercontent.com")
+.constant("GOOGLE_API_KEY","AIzaSyA7-XiSE26yWofo9OO0Za34DrgU5q775o4")
+.constant("FACEBOOK_APP_ID","1853899954884964")
.config(function($ionicConfigProvider) {
$ionicConfigProvider.navBar.alignTitle('center');
})
-.config(function(GooglePlusProvider) {
- GooglePlusProvider.init({
- clientId:'clientId',
- apiKey: 'apiKey'
- });
-})
-
-.config( function( $facebookProvider ) {
- $facebookProvider.setAppId('appid');
-})
-
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
diff --git a/www/js/controllers/facebook.js b/www/js/controllers/facebook.js
index f25e51f..b546146 100644
--- a/www/js/controllers/facebook.js
+++ b/www/js/controllers/facebook.js
@@ -8,59 +8,69 @@
* Controller of the appskeleton
*/
angular.module('appskeleton')
-.run( function( $rootScope ) {
- // Load the facebook SDK asynchronously
- (function(){
- // If we've already installed the SDK, we're done
- if (document.getElementById('facebook-jssdk')) {return;}
+// .run( function( $rootScope ) {
+// // Load the facebook SDK asynchronously
+// (function(){
+// // If we've already installed the SDK, we're done
+// if (document.getElementById('facebook-jssdk')) {return;}
- // Get the first script element, which we'll use to find the parent node
- var firstScriptElement = document.getElementsByTagName('script')[0];
+// // Get the first script element, which we'll use to find the parent node
+// var firstScriptElement = document.getElementsByTagName('script')[0];
- // Create a new script element and set its id
- var facebookJS = document.createElement('script');
- facebookJS.id = 'facebook-jssdk';
+// // Create a new script element and set its id
+// var facebookJS = document.createElement('script');
+// facebookJS.id = 'facebook-jssdk';
- // Set the new script's source to the source of the Facebook JS SDK
- facebookJS.src = '//connect.facebook.net/en_US/all.js';
+// // Set the new script's source to the source of the Facebook JS SDK
+// facebookJS.src = '//connect.facebook.net/en_US/all.js';
- // Insert the Facebook JS SDK into the DOM
- firstScriptElement.parentNode.insertBefore(facebookJS, firstScriptElement);
- }());
-})
+// // Insert the Facebook JS SDK into the DOM
+// firstScriptElement.parentNode.insertBefore(facebookJS, firstScriptElement);
+// }());
+// })
-.controller('FacebookCtrl', function ($scope,$window,$state,$facebook,socialsignin) {
+.controller('FacebookCtrl', function ($scope,$window,$state,socialsignin,FACEBOOK_APP_ID,$cordovaOauth) {
var FEmail=null;
var FullName=null;
-
+
$scope.SignInFacebook = function() {
- try{
- $facebook.login().then(function() {
- $scope.Refresh();
- });
- }
- catch(exception){
- $scope.FacebookMessage="Error connecting to Facebook! Try again later or use the login form."
- }
- };
+ $cordovaOauth.facebook(FACEBOOK_APP_ID, ["email","name"]).then(function(result) {
+ console.log(JSON.stringify(result));
+ var x=JSON.stringify(result);
+ $scope.FacebookMessage =x;
+ }, function(error) {
+ console.log(error);
+ $scope.FacebookMessage=error;
+ });
+};
+// $scope.SignInFacebook = function() {
+// try{
+// $facebook.login().then(function() {
+// $scope.Refresh();
+// });
+// }
+// catch(exception){
+// $scope.FacebookMessage="Error connecting to Facebook! Try again later or use the login form."
+// }
+// };
- $scope.Refresh = function() {
- $facebook.api("/me?fields=id,name,email").then(
- function(response) {
- FEmail=response.email;
- FullName=response.name;
- if(FEmail!=undefined){
- $scope.DoSignInFacebook();
- }
- else{
- $scope.FacebookMessage="No Email recieved from facebook! Try again later or use the login form."
- }
- },
- function(err) {
- $scope.FacebookMessage = "Error connecting to facebook! Try again later or use the login form.";
- });
- };
+// $scope.Refresh = function() {
+// $facebook.api("/me?fields=id,name,email").then(
+// function(response) {
+// FEmail=response.email;
+// FullName=response.name;
+// if(FEmail!=undefined){
+// $scope.DoSignInFacebook();
+// }
+// else{
+// $scope.FacebookMessage="No Email recieved from facebook! Try again later or use the login form."
+// }
+// },
+// function(err) {
+// $scope.FacebookMessage = "Error connecting to facebook! Try again later or use the login form.";
+// });
+// };
$scope.DoSignInFacebook=function(){
var FacebookObject={
diff --git a/www/js/controllers/google.js b/www/js/controllers/google.js
index 8bfeca6..98ac475 100644
--- a/www/js/controllers/google.js
+++ b/www/js/controllers/google.js
@@ -8,34 +8,44 @@
* Controller of the appskeleton
*/
angular.module('appskeleton')
- .controller('GoogleCtrl', function ($scope,$state,$window,socialsignin,GooglePlus) {
+ .controller('GoogleCtrl', function ($scope,$state,$window,socialsignin,GOOGLE_CLIENT_ID) {
var AuthToken=null;
var GEmail=null;
var FullName=null;
- $scope.SignInGoogle = function () {
- GooglePlus.login().then(function (authResult) {
- AuthToken=authResult.access_token;
- GooglePlus.getUser().then(function (user) {
- GEmail=user.email;
- FullName=user.name;
- if(GEmail!=undefined){
- $scope.DoSignInGoogle();
- }
- else{
- $scope.GoogleMessage="Error! Try again later or use the login form."
- }
- },
- function(err){
- $scope.GoogleMessage="Error! Try again later or use the login form."
- });
- },
- function (err) {
- $scope.GoogleMessage="Error connecting to Google! Try again later or use the login form."
- });
- };
+ $scope.googleLogin = function() {
+ var client_id=GOOGLE_CLIENT_ID;
+ var scope="email";
+ var redirect_uri="http://localhost/callback";
+ var response_type="token";
+ var Url="https://accounts.google.com/o/oauth2/auth?scope="+scope+"&client_id="+client_id+"&redirect_uri="+redirect_uri+
+ "&response_type="+response_type;
+ var ref = window.open(Url);
+ };
+
+ // $scope.SignInGoogle = function () {
+ // GooglePlus.login().then(function (authResult) {
+ // AuthToken=authResult.access_token;
+ // GooglePlus.getUser().then(function (user) {
+ // GEmail=user.email;
+ // FullName=user.name;
+ // if(GEmail!=undefined){
+ // $scope.DoSignInGoogle();
+ // }
+ // else{
+ // $scope.GoogleMessage="Error! Try again later or use the login form."
+ // }
+ // },
+ // function(err){
+ // $scope.GoogleMessage="Error! Try again later or use the login form."
+ // });
+ // },
+ // function (err) {
+ // $scope.GoogleMessage="Error connecting to Google! Try again later or use the login form."
+ // });
+ // };
//OPTIONAL
//Verified fields from google that can be accessed
//Full name
diff --git a/www/lib/angular-google-plus/.bower.json b/www/lib/angular-google-plus/.bower.json
deleted file mode 100644
index e9f3707..0000000
--- a/www/lib/angular-google-plus/.bower.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "name": "angular-google-plus",
- "version": "0.1.3",
- "homepage": "https://github.com/mrzmyr/angular-google-plus",
- "authors": [
- "Moritz Meyer "
- ],
- "main": "dist/angular-google-plus.js",
- "license": "MIT",
- "ignore": [
- "**/.*",
- "node_modules",
- "bower_components",
- "test",
- "tests"
- ],
- "dependencies": {
- "angular": ">=1.2.0 <=1.4"
- },
- "devDependencies": {
- "angular-mocks": ">=1.2.0 <=1.4"
- },
- "_release": "0.1.3",
- "_resolution": {
- "type": "version",
- "tag": "v0.1.3",
- "commit": "54954ca3eecc5d737f2ac4d4e26b750ec1d5c8bc"
- },
- "_source": "https://github.com/mrzmyr/angular-google-plus.git",
- "_target": "^0.1.3",
- "_originalSource": "angular-google-plus",
- "_direct": true
-}
\ No newline at end of file
diff --git a/www/lib/angular-google-plus/CHANGELOG.md b/www/lib/angular-google-plus/CHANGELOG.md
deleted file mode 100644
index ec75bab..0000000
--- a/www/lib/angular-google-plus/CHANGELOG.md
+++ /dev/null
@@ -1,41 +0,0 @@
-## 0.1.2
-
-- Bower: remove minifed version from main value
-- Dependencies: remove connect dependency (Gruntfile)
-- API: Add the getUser method and remove it from login (#1, #4)
-
-#### Breaking Changes
-
-The API for login has been changed (#4):
-
-**Before:**
-
-```javascript
-GooglePlus.login().then(function (user) {
- console.log(user);
-}, function (err) {
- console.log(err);
-});
-```
-
-**After:**
-
-```javascript
-GooglePlus.login().then(function (authResult) {
- console.log(authResult);
-
- GooglePlus.getUser().then(function (user) {
- console.log(user);
- });
-}, function (err) {
- console.log(err);
-});
-```
-
-## 0.1.1
-
-- added setToken / getToken methods
-
-## 0.1.0
-
-- Initial release
\ No newline at end of file
diff --git a/www/lib/angular-google-plus/Gruntfile.js b/www/lib/angular-google-plus/Gruntfile.js
deleted file mode 100644
index d4a511d..0000000
--- a/www/lib/angular-google-plus/Gruntfile.js
+++ /dev/null
@@ -1,69 +0,0 @@
-module.exports = function(grunt) {
- 'use strict';
-
- grunt.initConfig({
- pkg: grunt.file.readJSON('package.json'),
-
- jshint: {
- jshintrc: '.jshintrc',
- gruntfile: {
- src: 'Gruntfile.js'
- },
- source: {
- src: ['src/**/*.js', 'test/**/*.js']
- }
- },
- watch: {
- gruntfile: {
- files: '<%= jshint.gruntfile.src %>',
- tasks: ['jshint:gruntfile']
- },
- dist: {
- files: '<%= jshint.source.src %>',
- tasks: ['jshint', 'uglify:dist', 'uglify:src']
- }
- },
- uglify: {
- dist: {
- options: {
- banner: '/*! <%= pkg.name %> - v<%= pkg.version %> ' +
- '<%= grunt.template.today("yyyy-mm-dd") %> */\n'
- },
- files: {
- 'dist/angular-google-plus.min.js': ['src/angular-google-plus.js']
- }
- },
- src: {
- options: {
- beautify: true,
- compress: false,
- preserveComments: 'all',
- banner: '/*! <%= pkg.name %> - v<%= pkg.version %> ' +
- '<%= grunt.template.today("yyyy-mm-dd") %> */\n'
- },
- files: {
- 'dist/angular-google-plus.js': ['src/angular-google-plus.js']
- }
- }
- },
- karma: {
- unit: {
- configFile: 'karma.conf.js'
- },
- ci: {
- configFile: 'karma.conf.js',
- singleRun: true,
- browsers: ['PhantomJS']
- }
- }
- });
-
- // These plugins provide necessary tasks.
- grunt.loadNpmTasks('grunt-karma');
- grunt.loadNpmTasks('grunt-contrib-jshint');
- grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-contrib-uglify');
-
- // Default task.
- grunt.registerTask('default', ['jshint', 'uglify:dist', 'uglify:src']);
-};
diff --git a/www/lib/angular-google-plus/LICENSE b/www/lib/angular-google-plus/LICENSE
deleted file mode 100644
index ec06c8b..0000000
--- a/www/lib/angular-google-plus/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2013 Moritz Meyer
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/www/lib/angular-google-plus/README.md b/www/lib/angular-google-plus/README.md
deleted file mode 100644
index b4b4034..0000000
--- a/www/lib/angular-google-plus/README.md
+++ /dev/null
@@ -1,53 +0,0 @@
-angular-google-plus
-==================
-
-[](https://travis-ci.org/mrzmyr/angular-google-plus) [](http://badge.fury.io/js/angular-google-plus) [](http://badge.fury.io/bo/angular-google-plus)
-
-> A angular module which handles the login with the Google+ API
-
-#### Demo
-
-Try [this demo](http://plnkr.co/edit/jvHVtNedJoPcqRKg8OLz?p=preview). _Remind that there is no `API Key` and `Client ID` inserted_
-
-#### Install
-
-Install the angular module with bower or npm.
-
-```
-$ bower install angular-google-plus
-```
-
-```
-$ npm install angular-google-plus
-```
-
-#### Usage
-
-```js
-var app = angular.module('app', ['googleplus']);
-
-app.config(['GooglePlusProvider', function(GooglePlusProvider) {
- GooglePlusProvider.init({
- clientId: 'YOUR_CLIENT_ID',
- apiKey: 'YOUR_API_KEY'
- });
-}]);
-
-app.controller('AuthCtrl', ['$scope', 'GooglePlus', function ($scope, GooglePlus) {
- $scope.login = function () {
- GooglePlus.login().then(function (authResult) {
- console.log(authResult);
-
- GooglePlus.getUser().then(function (user) {
- console.log(user);
- });
- }, function (err) {
- console.log(err);
- });
- };
-}]);
-```
-
-#### Credits
-
-- Insperation from [jakemmarsh's gist](https://gist.github.com/jakemmarsh/5809963)
diff --git a/www/lib/angular-google-plus/bower.json b/www/lib/angular-google-plus/bower.json
deleted file mode 100644
index 70ad028..0000000
--- a/www/lib/angular-google-plus/bower.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "angular-google-plus",
- "version": "0.1.3",
- "homepage": "https://github.com/mrzmyr/angular-google-plus",
- "authors": [
- "Moritz Meyer "
- ],
- "main": "dist/angular-google-plus.js",
- "license": "MIT",
- "ignore": [
- "**/.*",
- "node_modules",
- "bower_components",
- "test",
- "tests"
- ],
- "dependencies": {
- "angular": ">=1.2.0 <=1.4"
- },
- "devDependencies": {
- "angular-mocks": ">=1.2.0 <=1.4"
- }
-}
diff --git a/www/lib/angular-google-plus/dist/angular-google-plus.js b/www/lib/angular-google-plus/dist/angular-google-plus.js
deleted file mode 100644
index b8ae6e7..0000000
--- a/www/lib/angular-google-plus/dist/angular-google-plus.js
+++ /dev/null
@@ -1,145 +0,0 @@
-/*! angular-google-plus - v0.1.3 2015-08-27 */
-/**
- * googleplus module
- */
-angular.module("googleplus", []).provider("GooglePlus", [ function() {
- /**
- * Options object available for module
- * options/services definition.
- * @type {Object}
- */
- var a = {};
- /**
- * clientId
- * @type {Number}
- */
- a.clientId = null;
- this.setClientId = function(b) {
- a.clientId = b;
- return this;
- };
- this.getClientId = function() {
- return a.clientId;
- };
- /**
- * apiKey
- * @type {String}
- */
- a.apiKey = null;
- this.setApiKey = function(b) {
- a.apiKey = b;
- return this;
- };
- this.getApiKey = function() {
- return a.apiKey;
- };
- /**
- * Scopes
- * @default 'https://www.googleapis.com/auth/plus.login'
- * @type {Boolean}
- */
- a.scopes = "https://www.googleapis.com/auth/plus.login";
- this.setScopes = function(b) {
- a.scopes = b;
- return this;
- };
- this.getScopes = function() {
- return a.scopes;
- };
- /**
- * Init Google Plus API
- */
- this.init = function(b) {
- angular.extend(a, b);
- };
- /**
- * Make sign-in server side
- */
- this.enableServerSide = function() {
- a.accessType = "offline";
- a.responseType = "code token id_token gsession";
- };
- /**
- * Make sign-in client side (default)
- */
- this.disableServerSide = function() {
- delete a.accessType;
- delete a.responseType;
- };
- /**
- * This defines the Google Plus Service on run.
- */
- this.$get = [ "$q", "$rootScope", "$timeout", function(b, c, d) {
- /**
- * Define a deferred instance that will implement asynchronous calls
- * @type {Object}
- */
- var e;
- /**
- * NgGooglePlus Class
- * @type {Class}
- */
- var f = function() {};
- f.prototype.login = function() {
- e = b.defer();
- var c = {
- client_id: a.clientId,
- scope: a.scopes,
- immediate: false
- };
- if (a.accessType && a.responseType) {
- c.access_type = a.accessType;
- c.response_type = a.responseType;
- }
- gapi.auth.authorize(c, this.handleAuthResult);
- return e.promise;
- };
- f.prototype.checkAuth = function() {
- gapi.auth.authorize({
- client_id: a.clientId,
- scope: a.scopes,
- immediate: true
- }, this.handleAuthResult);
- };
- f.prototype.handleClientLoad = function() {
- gapi.client.setApiKey(a.apiKey);
- gapi.auth.init(function() {});
- d(this.checkAuth, 1);
- };
- f.prototype.handleAuthResult = function(a) {
- if (a && !a.error) {
- e.resolve(a);
- c.$apply();
- } else {
- e.reject("error");
- }
- };
- f.prototype.getUser = function() {
- var a = b.defer();
- gapi.client.load("oauth2", "v2", function() {
- gapi.client.oauth2.userinfo.get().execute(function(b) {
- a.resolve(b);
- c.$apply();
- });
- });
- return a.promise;
- };
- f.prototype.getToken = function() {
- return gapi.auth.getToken();
- };
- f.prototype.setToken = function(a) {
- return gapi.auth.setToken(a);
- };
- f.prototype.logout = function() {
- gapi.auth.signOut();
- };
- return new f();
- } ];
-} ]).run([ function() {
- var a = document.createElement("script");
- a.type = "text/javascript";
- a.async = true;
- a.src = "https://apis.google.com/js/client.js";
- var b = document.getElementsByTagName("script")[0];
- b.parentNode.insertBefore(a, b);
-} ]);
\ No newline at end of file
diff --git a/www/lib/angular-google-plus/dist/angular-google-plus.min.js b/www/lib/angular-google-plus/dist/angular-google-plus.min.js
deleted file mode 100644
index b49fe54..0000000
--- a/www/lib/angular-google-plus/dist/angular-google-plus.min.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/*! angular-google-plus - v0.1.3 2015-08-27 */
-angular.module("googleplus",[]).provider("GooglePlus",[function(){var a={};a.clientId=null,this.setClientId=function(b){return a.clientId=b,this},this.getClientId=function(){return a.clientId},a.apiKey=null,this.setApiKey=function(b){return a.apiKey=b,this},this.getApiKey=function(){return a.apiKey},a.scopes="https://www.googleapis.com/auth/plus.login",this.setScopes=function(b){return a.scopes=b,this},this.getScopes=function(){return a.scopes},this.init=function(b){angular.extend(a,b)},this.enableServerSide=function(){a.accessType="offline",a.responseType="code token id_token gsession"},this.disableServerSide=function(){delete a.accessType,delete a.responseType},this.$get=["$q","$rootScope","$timeout",function(b,c,d){var e,f=function(){};return f.prototype.login=function(){e=b.defer();var c={client_id:a.clientId,scope:a.scopes,immediate:!1};return a.accessType&&a.responseType&&(c.access_type=a.accessType,c.response_type=a.responseType),gapi.auth.authorize(c,this.handleAuthResult),e.promise},f.prototype.checkAuth=function(){gapi.auth.authorize({client_id:a.clientId,scope:a.scopes,immediate:!0},this.handleAuthResult)},f.prototype.handleClientLoad=function(){gapi.client.setApiKey(a.apiKey),gapi.auth.init(function(){}),d(this.checkAuth,1)},f.prototype.handleAuthResult=function(a){a&&!a.error?(e.resolve(a),c.$apply()):e.reject("error")},f.prototype.getUser=function(){var a=b.defer();return gapi.client.load("oauth2","v2",function(){gapi.client.oauth2.userinfo.get().execute(function(b){a.resolve(b),c.$apply()})}),a.promise},f.prototype.getToken=function(){return gapi.auth.getToken()},f.prototype.setToken=function(a){return gapi.auth.setToken(a)},f.prototype.logout=function(){gapi.auth.signOut()},new f}]}]).run([function(){var a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src="https://apis.google.com/js/client.js";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b)}]);
\ No newline at end of file
diff --git a/www/lib/angular-google-plus/karma.conf.js b/www/lib/angular-google-plus/karma.conf.js
deleted file mode 100644
index caeec04..0000000
--- a/www/lib/angular-google-plus/karma.conf.js
+++ /dev/null
@@ -1,67 +0,0 @@
-// Karma configuration
-// Generated on Sat Oct 19 2013 13:04:35 GMT+0200 (CEST)
-
-module.exports = function(config) {
- config.set({
-
- // base path, that will be used to resolve files and exclude
- basePath: '',
-
-
- // frameworks to use
- frameworks: ['jasmine'],
-
-
- // list of files / patterns to load in the browser
- files: [
- 'bower_components/angular/angular.js',
- 'bower_components/angular-mocks/angular-mocks.js',
- 'src/*.js',
- 'test/**/*.spec.js'
- ],
-
- // list of files to exclude
- exclude: [],
-
- // test results reporter to use
- // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
- reporters: ['progress'],
-
-
- // web server port
- port: 9876,
-
-
- // enable / disable colors in the output (reporters and logs)
- colors: true,
-
-
- // level of logging
- // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
- logLevel: config.LOG_INFO,
-
-
- // enable / disable watching file and executing tests whenever any file changes
- autoWatch: true,
-
-
- // Start these browsers, currently available:
- // - Chrome
- // - ChromeCanary
- // - Firefox
- // - Opera
- // - Safari (only Mac)
- // - PhantomJS
- // - IE (only Windows)
- browsers: ['Opera', 'Chrome', 'Firefox', 'Safari', 'PhantomJS'],
-
-
- // If browser does not capture in given timeout [ms], kill it
- captureTimeout: 60000,
-
-
- // Continuous Integration mode
- // if true, it capture browsers, run tests and exit
- singleRun: false
- });
-};
diff --git a/www/lib/angular-google-plus/package.json b/www/lib/angular-google-plus/package.json
deleted file mode 100644
index ee871ae..0000000
--- a/www/lib/angular-google-plus/package.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "name": "angular-google-plus",
- "version": "0.1.3",
- "description": "A angular module which handles the login with the Google+ API",
- "main": "Gruntfile.js",
- "scripts": {
- "test": "grunt karma:ci"
- },
- "repository": {
- "type": "git",
- "url": "git://github.com/mrzmyr/angular-google-plus.git"
- },
- "keywords": [
- "google",
- "plus",
- "angular",
- "login",
- "api"
- ],
- "bugs": {
- "url": "https://github.com/mrzmyr/angular-google-plus/issues"
- },
- "author": "Moritz Meyer ",
- "license": "MIT",
- "readmeFilename": "README.md",
- "gitHead": "e6875b80904f553b9f6fddae1efce1d5d7008483",
- "devDependencies": {
- "grunt": "~0.4.1",
- "grunt-contrib-jshint": "^0.11.2",
- "grunt-contrib-uglify": "^0.9.1",
- "grunt-contrib-watch": "~0.6.1",
- "grunt-karma": "^0.12.0",
- "jasmine-core": "^2.3.4",
- "karma": "^0.13.9",
- "karma-chrome-launcher": "^0.2.0",
- "karma-coffee-preprocessor": "^0.3.0",
- "karma-firefox-launcher": "~0.1.0",
- "karma-html2js-preprocessor": "~0.1.0",
- "karma-jasmine": "~0.3.0",
- "karma-opera-launcher": "^0.3.0",
- "karma-phantomjs-launcher": "^0.2.0",
- "karma-safari-launcher": "~0.1.1",
- "karma-script-launcher": "~0.1.0",
- "phantomjs": "^1.9.17"
- }
-}
diff --git a/www/lib/angular-google-plus/src/angular-google-plus.js b/www/lib/angular-google-plus/src/angular-google-plus.js
deleted file mode 100644
index 986887e..0000000
--- a/www/lib/angular-google-plus/src/angular-google-plus.js
+++ /dev/null
@@ -1,184 +0,0 @@
-
-/**
- * googleplus module
- */
-angular.module('googleplus', []).
-
- /**
- * GooglePlus provider
- */
- provider('GooglePlus', [function() {
-
- /**
- * Options object available for module
- * options/services definition.
- * @type {Object}
- */
- var options = {};
-
- /**
- * clientId
- * @type {Number}
- */
- options.clientId = null;
-
- this.setClientId = function(clientId) {
- options.clientId = clientId;
- return this;
- };
-
- this.getClientId = function() {
- return options.clientId;
- };
-
- /**
- * apiKey
- * @type {String}
- */
- options.apiKey = null;
-
- this.setApiKey = function(apiKey) {
- options.apiKey = apiKey;
- return this;
- };
-
- this.getApiKey = function() {
- return options.apiKey;
- };
-
- /**
- * Scopes
- * @default 'https://www.googleapis.com/auth/plus.login'
- * @type {Boolean}
- */
- options.scopes = 'https://www.googleapis.com/auth/plus.login';
-
- this.setScopes = function(scopes) {
- options.scopes = scopes;
- return this;
- };
-
- this.getScopes = function() {
- return options.scopes;
- };
-
- /**
- * Init Google Plus API
- */
- this.init = function(customOptions) {
- angular.extend(options, customOptions);
- };
-
- /**
- * Make sign-in server side
- */
- this.enableServerSide = function () {
- options.accessType = 'offline';
- options.responseType = 'code token id_token gsession';
- };
-
- /**
- * Make sign-in client side (default)
- */
- this.disableServerSide = function () {
- delete options.accessType;
- delete options.responseType;
- };
-
- /**
- * This defines the Google Plus Service on run.
- */
- this.$get = ['$q', '$rootScope', '$timeout', function($q, $rootScope, $timeout) {
-
- /**
- * Define a deferred instance that will implement asynchronous calls
- * @type {Object}
- */
- var deferred;
-
- /**
- * NgGooglePlus Class
- * @type {Class}
- */
- var NgGooglePlus = function () {};
-
- NgGooglePlus.prototype.login = function () {
- deferred = $q.defer();
-
- var authOptions = {
- client_id: options.clientId,
- scope: options.scopes,
- immediate: false
- };
-
- if(options.accessType && options.responseType) {
- authOptions.access_type = options.accessType;
- authOptions.response_type = options.responseType;
- }
-
- gapi.auth.authorize(authOptions, this.handleAuthResult);
-
- return deferred.promise;
- };
-
- NgGooglePlus.prototype.checkAuth = function() {
- gapi.auth.authorize({
- client_id: options.clientId,
- scope: options.scopes,
- immediate: true
- }, this.handleAuthResult);
- };
-
- NgGooglePlus.prototype.handleClientLoad = function () {
- gapi.client.setApiKey(options.apiKey);
- gapi.auth.init(function () { });
- $timeout(this.checkAuth, 1);
- };
-
- NgGooglePlus.prototype.handleAuthResult = function(authResult) {
- if (authResult && !authResult.error) {
- deferred.resolve(authResult);
- $rootScope.$apply();
- } else {
- deferred.reject('error');
- }
- };
-
- NgGooglePlus.prototype.getUser = function() {
- var deferred = $q.defer();
-
- gapi.client.load('oauth2', 'v2', function () {
- gapi.client.oauth2.userinfo.get().execute(function (resp) {
- deferred.resolve(resp);
- $rootScope.$apply();
- });
- });
-
- return deferred.promise;
- };
-
- NgGooglePlus.prototype.getToken = function() {
- return gapi.auth.getToken();
- };
-
- NgGooglePlus.prototype.setToken = function(token) {
- return gapi.auth.setToken(token);
- };
-
- NgGooglePlus.prototype.logout = function () {
- gapi.auth.signOut();
- };
-
- return new NgGooglePlus();
- }];
-}])
-
-// Initialization of module
-.run([function() {
- var po = document.createElement('script');
- po.type = 'text/javascript';
- po.async = true;
- po.src = 'https://apis.google.com/js/client.js';
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(po, s);
-}]);
diff --git a/www/lib/ng-cordova-oauth/.bower.json b/www/lib/ng-cordova-oauth/.bower.json
new file mode 100644
index 0000000..783a302
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/.bower.json
@@ -0,0 +1,41 @@
+{
+ "name": "ng-cordova-oauth",
+ "main": "dist/ng-cordova-oauth.js",
+ "version": "0.3.0",
+ "homepage": "https://github.com/nraboy/ng-cordova-oauth",
+ "authors": [
+ "Nic Raboy "
+ ],
+ "description": "AngularJS oauth library for use with Apache Cordova projects",
+ "moduleType": [
+ "node"
+ ],
+ "keywords": [
+ "ng-cordova-oauth",
+ "ngcordova",
+ "angularjs",
+ "ionic",
+ "oauth",
+ "apache cordova",
+ "phonegap",
+ "ionic framework"
+ ],
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ],
+ "_release": "0.3.0",
+ "_resolution": {
+ "type": "version",
+ "tag": "0.3.0",
+ "commit": "555b5caafbe0b7a552c6dc418e3353f6615f24da"
+ },
+ "_source": "https://github.com/nraboy/ng-cordova-oauth.git",
+ "_target": "^0.3.0",
+ "_originalSource": "ng-cordova-oauth",
+ "_direct": true
+}
\ No newline at end of file
diff --git a/www/lib/ng-cordova-oauth/CHANGELOG.md b/www/lib/ng-cordova-oauth/CHANGELOG.md
new file mode 100644
index 0000000..b950af2
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/CHANGELOG.md
@@ -0,0 +1,120 @@
+0.2.8 -
+
+* Add Trakt.tv support
+
+0.2.7 - May 17, 2016
+
+* Fix `Can't find variable: requestToken` error for various providers
+
+0.2.6 - May 12, 2016
+
+* Add Xing support
+* Add Netatmo support
+* Add 500px support
+
+0.2.5 - April 1, 2016
+
+* Fix variable definitions that are conflicting with other libraries
+* Localize header settings
+
+0.2.3 - February 10, 2016
+
+* Fix issue with Apache Cordova 6.0 where the InAppBrowser plugin now holds a new name
+* Rename all factories to avoid conflict with other libraries
+
+0.2.2 - January 6, 2016
+
+* Update Karma
+
+0.2.1 - January 6, 2016
+
+* Add support for authorization code flow for Spotify
+
+0.2.0 - November 22, 2015
+
+* Fix InAppBrowser issue with Apache Cordova 5.4.0
+* Complete code refactor for future maintainability
+* Add a few test cases
+
+0.1.4 - June 28, 2015
+
+* Add Envato support
+* Add optional `options` parameter to more providers
+* Add optional re-request for permissions to Facebook provider
+
+0.1.3 - June 7, 2015
+
+* Refactor code to function as submodule
+* Add Family Search support
+
+0.1.2 - May 24, 2015
+
+* Add Windows Live Connect support
+* Add Yammer support
+* Add Venmo support
+* Add Stripe support
+* Add Rally support
+* Apache Cordova Whitelist plugin is now required and is noted in the documentation
+
+0.1.1 - May 4, 2015
+
+* Fix InAppBrowser checks to `cordova-plugin-inappbrowser` instead of `org.apache.cordova.inappbrowser`
+* Minor code cleanup
+
+0.1.0 - March 14, 2015
+
+* Add optional `options` parameter to implicit grant providers
+* Add Spotify provider support
+* Fix Facebook to use API v2.0 instead of the ending v1.0
+* Fix Twitter to meet needs of changed API
+
+0.0.9 - March 5, 2015
+
+* Add Imgur support
+
+0.0.8 - January 13, 2015
+
+* Add vkontakte support
+* Add ADFS support
+* Add timeout to browser close
+
+0.0.7 - January 7, 2015
+
+* Add Magento support
+
+0.0.6 - December 22, 2014
+
+* Fix/Add: Nonce method to the $cordovaOauthUtility factory
+* Fix: Handle browser cancel events
+* Add Withings support
+* Add Foursquare support
+
+0.0.5 - December 7, 2014
+
+* Add Salesfoce support
+* Add Strava support
+
+0.0.4 - November 22, 2014
+
+* Add Meetup support
+
+0.0.3 - November 20, 2014
+
+* Add Twitter support
+* Check if InAppBrowser is installed
+
+0.0.2 - November 4, 2014
+
+* Add LinkedIn support
+* Add Instagram support
+* Add Box support
+* Add Reddit support
+* Use implicit grant for Google service
+
+0.0.1 - October 20, 2014
+
+* Add Digital Ocean support
+* Add Dropbox support
+* Add Google support
+* Add GitHub support
+* Add Facebook support
diff --git a/www/lib/ng-cordova-oauth/Gruntfile.js b/www/lib/ng-cordova-oauth/Gruntfile.js
new file mode 100644
index 0000000..53ec1c9
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/Gruntfile.js
@@ -0,0 +1,52 @@
+module.exports = function(grunt) {
+
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+ concat: {
+ options: {
+ },
+ dist: {
+ src: ['src/*.js'],
+ dest: 'dist/<%= pkg.name %>.js',
+ },
+ },
+
+ uglify: {
+ options: {
+ banner: '// <%= pkg.name %> - v<%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd") %>)\n' + '// http://www.nraboy.com\n'
+ },
+ build: {
+ src: ['src/*.js'],
+ dest: 'dist/<%= pkg.name %>.min.js'
+ }
+ },
+ jshint: {
+ all: ['src/*.js']
+ },
+ clean: {
+ js: ['dist/*.min.js']
+ },
+ karma: {
+ options: {
+ configFile: 'karma.conf.js'
+ },
+ continuos: {
+ singleRun: true,
+ autoWatch: false
+ },
+ dev: {}
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-karma');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ grunt.loadNpmTasks('grunt-contrib-concat');
+
+ grunt.registerTask('test:dev', ['clean', 'jshint', 'karma:dev']);
+ grunt.registerTask('test', ['clean', 'jshint', 'karma:continuos']);
+ grunt.registerTask('build', ['clean', 'jshint', 'concat', 'uglify']);
+ grunt.registerTask('default', ['clean', 'jshint', 'karma:continuos', 'concat', 'uglify']);
+
+};
diff --git a/www/lib/ng-facebook/LICENSE b/www/lib/ng-cordova-oauth/LICENSE
similarity index 87%
rename from www/lib/ng-facebook/LICENSE
rename to www/lib/ng-cordova-oauth/LICENSE
index bd367e5..582b935 100644
--- a/www/lib/ng-facebook/LICENSE
+++ b/www/lib/ng-cordova-oauth/LICENSE
@@ -1,6 +1,6 @@
-The MIT License
+The MIT License (MIT)
-Copyright (c) 2014, GoDisco
+Copyright (c) 2014 Nic Raboy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,14 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/www/lib/ng-cordova-oauth/README.md b/www/lib/ng-cordova-oauth/README.md
new file mode 100644
index 0000000..24f7825
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/README.md
@@ -0,0 +1,204 @@
+[](https://travis-ci.org/nraboy/ng-cordova-oauth)
+[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XK2JBEZ2PD2QS)
+
+# ngCordovaOauth
+
+ngCordovaOauth is an AngularJS Apache Cordova Oauth library. The purpose of this library is to quickly and easily obtain an access token from various web services to use their APIs.
+
+If you are using Angular 2, you should check out [ng2-cordova-oauth](https://github.com/nraboy/ng2-cordova-oauth) instead.
+
+
+## Requirements
+
+* Apache Cordova 3.5+
+* AngularJS
+* [Apache Cordova InAppBrowser Plugin](http://cordova.apache.org/docs/en/3.0.0/cordova_inappbrowser_inappbrowser.md.html)
+* [Apache Cordova Whitelist Plugin](https://github.com/apache/cordova-plugin-whitelist)
+* [jsSHA 1.6.0](https://github.com/Caligatio/jsSHA) Secure Hash Library (Twitter, Withings, and Magento only)
+
+
+## Installing ngCordovaOauth Into Your Project
+
+### Bower way:
+
+Add this repository as dependency:
+
+ $ bower install ng-cordova-oauth -S
+
+This action will set the dependency and add it to the `bower.json` file.
+
+The JavaScript library must then be added to your **index.html** file found in your projects **www**
+directory:
+
+
+
+### Outdated way:
+
+Copy the following file from this repository to your Apache Cordova project:
+
+ $ cd ng-cordova-oauth
+ $ cp ng-cordova-oauth.js /path/to/project/www/js/ng-cordova-oauth.min.js
+
+The JavaScript library must then be added to your **index.html** file found in your projects **www**
+directory:
+
+
+
+### Injecting:
+
+Once added to your index.html file, you must inject the library into your **app.js** module. Make your
+**app.js** file look something like the following:
+
+ angular.module('starter', ['ionic', 'ngCordovaOauth'])
+
+At this point, ngCordovaOauth is installed into your project and is ready for use.
+
+
+## Using ngCordovaOauth In Your Project
+
+Each web service API acts independently in this library. However, when configuring each web service, one thing must remain consistent. You must use **http://localhost/callback** as your callback / redirect URI. This is because this library will perform tasks when this URL is found.
+
+ $cordovaOauth.azureAD(string clientId, string tenantId, string resourceURL);
+ $cordovaOauth.dropbox(string appKey, object options);
+ $cordovaOauth.digitalOcean(string clientId, string clientSecret, object options);
+ $cordovaOauth.github(string clientId, string clientSecret, array appScope, object options);
+ $cordovaOauth.facebook(string clientId, array appScope, object options);
+ $cordovaOauth.linkedin(string clientId, string clientSecret, array appScope, string state);
+ $cordovaOauth.instagram(string clientId, array appScope, object options);
+ $cordovaOauth.box(string clientId, string clientSecret, string state, object options);
+ $cordovaOauth.reddit(string clientId, string clientSecret, array appScope, object options);
+ $cordovaOauth.twitter(string consumerKey, string consumerSecretKey, object options);
+ $cordovaOauth.meetup(string consumerKey, object options);
+ $cordovaOauth.salesforce(string loginUrl, string clientId);
+ $cordovaOauth.strava(string clientId, string clientSecret, array appScope, object options);
+ $cordovaOauth.withings(string clientId, string clientSecret);
+ $cordovaOauth.foursquare(string clientId, object options);
+ $cordovaOauth.magento(string baseUrl, string clientId, string clientSecret)
+ $cordovaOauth.vkontakte(string clientId, array appScope)
+ $cordovaOauth.adfs(string clientId, string adfsServer, string relyingPartyId)
+ $cordovaOauth.imgur(string clientId, object options)
+ $cordovaOauth.spotify(string clientId, array appScope, object options)
+ $cordovaOauth.uber(string clientId, array appScope, object options)
+ $cordovaOauth.windowsLive(string clientId, array appScope, object options)
+ $cordovaOauth.yammer(string clientId, object options)
+ $cordovaOauth.venmo(string clientId, array appScope, object options)
+ $cordovaOauth.stripe(string clientId, string clientSecret, string appScope, object options)
+ $cordovaOauth.slack(string clientId, string clientSecret, array appScope, object options)
+ $cordovaOauth.rally(string clientId, string clientSecret, string appScope, object options)
+ $cordovaOauth.familySearch(string clientId, string state, object options);
+ $cordovaOauth.envato(string clientId, object options);
+ $cordovaOauth.weibo(string clientId, string clientSecret, array appScope, object options);
+ $cordovaOauth.untappd(string clientId, object options);
+ $cordovaOauth.pocket(string clientId, object options);
+ $cordovaOauth.xing(string clientId, string clientSecret, object options);
+ $cordovaOauth.fiveHundredsPx(string sdkKey, object options);
+ $cordovaOauth.netatmo(object options);
+ $cordovaOauth.trakttv(string clientId, string clientSecret, string state);
+
+Each API call returns a promise. The success callback will provide a response object and the error
+callback will return a string.
+
+```javascript
+$cordovaOauth.google("CLIENT_ID_HERE", ["email"]).then(function(result) {
+ console.log("Response Object -> " + JSON.stringify(result));
+}, function(error) {
+ console.log("Error -> " + error);
+});
+```
+
+To authenticate with Twitter, Withings, Magento and Xing an additional library is required. These services require HMAC-SHA1 signatures in their Oauth implementation. Including the sha1.js component of jsSHA will accomplish this task.
+
+As of Apache Cordova 5.0.0, the [whitelist plugin](https://www.thepolyglotdeveloper.com/2015/05/whitelist-external-resources-for-use-in-ionic-framework/) must be used in order to reach external web services.
+
+### Important Note About Testing
+
+This library will **NOT** work with a web browser, ionic serve, ionic live-reload, or ionic view. It **MUST** be used via installing to a device or simulator.
+
+### Important Note About Google
+
+Google, as of October 2016, has started blocking requests from web views commonly found in hybrid applications. For this reason, support for Google has been removed from this library.
+
+More information can be found at:
+
+[https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html](https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html)
+
+## Content-Security-Policy
+
+When using the Content-Security-Policy as mentioned in the [Apache Cordova Whitelist Plugin](https://github.com/apache/cordova-plugin-whitelist) documentation, you'll need to allow content from the OAuth Provider. For example, if using Google Login, you'll need to add `https://www.googleapis.com` to your `default-src` list. Your meta tag would look something like this for Google and Facebook:
+```html
+
+```
+
+## Version History
+
+[View CHANGELOG](CHANGELOG.md)
+
+
+## Contribution Rules
+
+All contributions must be made via the `development` branch. This keeps the project more maintainable in terms of versioning as well as code control.
+
+If you want to contribute please use the new architecture of files. Each provider need to be in a separated file following this pattern: `oauth..js` and add it to the `oauth.provider` module as a dependency.
+
+(If you have any doubt about the architecture take a look other providers to see how it is.)
+
+
+```javascript
+//oauth.js
+
+angular.module("oauth.providers", [
+ "oauth.utils", "oauth.azuread", "oauth.adfs", 'oauth.dropbox',
+ 'oauth.digitalOcean', 'oauth.google', 'oauth.github', 'oauth.facebook',
+ 'oauth.linkedin', 'oauth.instagram', 'oauth.box', 'oauth.reddit', 'oauth.slack',
+ 'oauth.twitter', 'oauth.meetup', 'oauth.salesforce', 'oauth.strava',
+ 'oauth.withings', 'oauth.foursquare', 'oauth.magento', 'oauth.vkontakte',
+ 'oauth.odnoklassniki', 'oauth.imgur', 'oauth.spotify', 'oauth.uber',
+ 'oauth.windowslive', 'oauth.yammer', 'oauth.venmo', 'oauth.stripe', 'oauth.rally',
+ 'oauth.familySearch', 'oauth.envato', 'oauth.weibo', 'oauth.jawbone', 'oauth.untappd',
+ 'oauth.dribble', '']).factory("$cordovaOauth", cordovaOauth);
+
+function cordovaOauth(
+ $q, $http, $cordovaOauthUtility, $azureAD, $adfs, $dropbox, $digitalOcean,
+ $google, $github, $facebook, $linkedin, $instagram, $box, $reddit, $slack,
+ $twitter, $meetup, $salesforce, $strava, $withings, $foursquare, $magento
+ $vkontakte, $odnoklassniki, $imgur, $spotify, $uber, $windowslive, $yammer,
+ $venmo, $stripe, $rally, $familySearch, $envato, $weibo, $jawbone, $untappd,
+ $dribble, ) {
+
+ return {
+ // A lot of providers...
+ yourProvider: $yourProvider.signinFuncion,
+ }
+}
+
+$cordovaOauth.$inject = [
+ "$q", '$http', "$cordovaOauthUtility", "$azureAD", "$adfs", '$dropbox',
+ '$digitalOcean', '$google', '$github', '$facebook', '$linkedin',
+ '$instagram', '$box', '$reddit', '$slack', '$twitter' '$meetup', '$salesforce',
+ '$strava', '$withings', '$foursquare', '$magento', '$vkontakte',
+ '$odnoklassniki', '$imgur', '$spotify', '$uber', '$windowslive', '$yammer',
+ '$venmo', '$stripe', '$rally', '$familySearch', '$envato', '$weibo',
+ '$jawbone', '$untappd', '$dribble', ''
+];
+```
+
+## Support
+
+This project is maintained by **Nic Raboy** and **Matheus Rocha**. This plugin is and will always be open source. That said, support is not. If you'd like to **purchase** paid support for this library, please contact either of us on Twitter.
+
+Nic Raboy on Twitter - [@nraboy](https://www.twitter.com/nraboy)
+
+Matheus Rocha on Twitter - [@matheusrocha](https://www.twitter.com/matheusrocha)
+
+The issue tracker is to be used for bug reporting only. We will not help you build your application, diagnose your problems, or teach you how to use the various oauth providers through the issue tracker. Free support can be found in the forums or on Stack Overflow.
+
+
+## Resources
+
+Ionic Framework - [http://www.ionicframework.com](http://www.ionicframework.com)
+
+AngularJS - [http://www.angularjs.org](http://www.angularjs.org)
+
+Apache Cordova - [http://cordova.apache.org](http://cordova.apache.org)
+
+The Polyglot Developer - [https://www.thepolyglotdeveloper.com](https://www.thepolyglotdeveloper.com)
diff --git a/www/lib/ng-cordova-oauth/bower.json b/www/lib/ng-cordova-oauth/bower.json
new file mode 100644
index 0000000..cdb0cba
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/bower.json
@@ -0,0 +1,31 @@
+{
+ "name": "ng-cordova-oauth",
+ "main": "dist/ng-cordova-oauth.js",
+ "version": "0.3.0",
+ "homepage": "https://github.com/nraboy/ng-cordova-oauth",
+ "authors": [
+ "Nic Raboy "
+ ],
+ "description": "AngularJS oauth library for use with Apache Cordova projects",
+ "moduleType": [
+ "node"
+ ],
+ "keywords": [
+ "ng-cordova-oauth",
+ "ngcordova",
+ "angularjs",
+ "ionic",
+ "oauth",
+ "apache cordova",
+ "phonegap",
+ "ionic framework"
+ ],
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ]
+}
diff --git a/www/lib/ng-cordova-oauth/dist/ng-cordova-oauth.js b/www/lib/ng-cordova-oauth/dist/ng-cordova-oauth.js
new file mode 100644
index 0000000..476f266
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/dist/ng-cordova-oauth.js
@@ -0,0 +1,3363 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.500px', ['oauth.utils'])
+ .factory('$ngCordova500px', fiveHundredsPx);
+
+ function fiveHundredsPx($q, $http, $cordovaOauthUtility) {
+ return { signin: oauth500px };
+
+ /*
+ * Sign into the 500px service
+ *
+ * @param string sdkKey
+ * @param object options
+ * @return promise
+ */
+ function oauth500px(sdkKey, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://api.500px.com/v1/api/js-sdk/authorize?sdk_key=' + sdkKey + '&callback=' + redirect_uri, '_blank', 'toolbar=no,zoom=no,location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var accessToken = (event.url).split("#token:")[1].split(',')[0];
+ deferred.resolve({error: false, success: true, access_token: accessToken, callback: redirect_uri});
+ } else {
+ deferred.reject({success: false, callback: redirect_uri, error: true, access_token: null});
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ fiveHundredsPx.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.adfs', ['oauth.utils'])
+ .factory('$ngCordovaAdfs', adfs);
+
+ function adfs($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthAdfs };
+
+ /*
+ * Sign into the ADFS service (ADFS 3.0 onwards)
+ *
+ * @param string clientId (client registered in ADFS, with redirect_uri configured to: http://localhost/callback)
+ * @param string adfsServer (url of the ADFS Server)
+ * @param string relyingPartyId (url of the Relying Party (resource relying on ADFS for authentication) configured in ADFS)
+ * @return promise
+ */
+ function oauthAdfs(clientId, adfsServer, relyingPartyId) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var browserRef = window.cordova.InAppBrowser.open(adfsServer + '/adfs/oauth2/authorize?response_type=code&client_id=' + clientId +'&redirect_uri=http://localhost/callback&resource=' + relyingPartyId, '_blank', 'location=no');
+
+ browserRef.addEventListener("loadstart", function(event) {
+ if((event.url).indexOf('http://localhost/callback') === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, url: adfsServer + "/adfs/oauth2/token", data: "client_id=" + clientId + "&code=" + requestToken + "&redirect_uri=http://localhost/callback&grant_type=authorization_code" })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ adfs.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.azuread', ['oauth.utils'])
+ .factory('$ngCordovaAzureAD', azureAD);
+
+ function azureAD($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthAzureAD };
+
+ /*
+ * Sign into the Azure AD Authentication Library
+ *
+ * @param string clientId (client registered in ADFS, with redirect_uri configured to: http://localhost/callback)
+ * @param string tenantId (the tenants UUID, can be found in oauth endpoint)
+ * @param string resourceURL (This is your APP ID URI in Azure Config)
+ * @return promise
+ */
+ function oauthAzureAD(clientId, tenantId, resourceURL) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+
+ var browserRef = window.cordova.InAppBrowser.open('https://login.microsoftonline.com/' + tenantId + '/oauth2/authorize?response_type=code&client_id=' + clientId + '&redirect_uri=http://localhost/callback', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener("loadstart", function(event) {
+ if((event.url).indexOf('http://localhost/callback') === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ console.log(requestToken);
+
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, url: "https://login.microsoftonline.com/" + tenantId + "/oauth2/token", data:
+ "client_id=" + clientId +
+ "&code=" + requestToken +
+ "&redirect_uri=http://localhost/callback&" +
+ "grant_type=authorization_code&" +
+ "resource=" + resourceURL})
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ azureAD.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.box', ['oauth.utils'])
+ .factory('$ngCordovaBox', box);
+
+ function box($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthBox };
+
+ /*
+ * Sign into the Box service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string appState
+ * @param object options
+ * @return promise
+ */
+ function oauthBox(clientId, clientSecret, appState, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://app.box.com/api/oauth2/authorize/?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&state=' + appState + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, url: "https://app.box.com/api/oauth2/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ box.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.digitalOcean', ['oauth.utils'])
+ .factory('$ngCordovaDigitalOcean', digitalOcean);
+
+ function digitalOcean($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthDigitalOcean };
+
+ /*
+ * Sign into the Digital Ocean service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param object options
+ * @return promise
+ */
+ function oauthDigitalOcean(clientId, clientSecret, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open("https://cloud.digitalocean.com/v1/oauth/authorize?client_id=" + clientId + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=read%20write", "_blank", "location=no,clearsessioncache=yes,clearcache=yes");
+ browserRef.addEventListener("loadstart", function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, url: "https://cloud.digitalocean.com/v1/oauth/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ digitalOcean.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.dribble', ['oauth.utils'])
+ .factory('$ngCordovaDribble', dribble);
+
+ function dribble($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthDribble };
+
+ /*
+ * Sign into the Dribble service
+ *
+ * @param string clientId REQUIRED
+ * @param string clientSecret REQUIRED
+ * @param object Array appScope REQUIRED
+ * @param object options (redirect_uri) OPTIONAL
+ * @param state string OPTIONAL
+ * @return promise
+ */
+ function oauthDribble(clientId, clientSecret, appScope, options, state) {
+
+ var deferred = $q.defer();
+ if (window.cordova) {
+ if ($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ var OAUTH_URL = 'https://dribbble.com/oauth/authorize';
+ var ACCESS_TOKEN_URL = 'https://dribbble.com/oauth/token';
+ if (options !== undefined) {
+ if (options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+
+ if (state === undefined) {
+ state = $cordovaOauthUtility.createNonce(5);
+ }
+
+ var scope = appScope.join(",").replace(/,/g, '+'); //dribble scopes are passed with +
+ var browserRef = window.cordova.InAppBrowser.open(OAUTH_URL + '?client_id=' + clientId + '&redirect_uri=' + redirect_uri +
+ '&scope=' + scope + '&state=' + state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function (event) {
+ if ((event.url).indexOf(redirect_uri) === 0) {
+ var callBackCode = (event.url).split("code=")[1];
+ var code = callBackCode.split("&")[0];
+
+ $http({
+ method: "post",
+ headers: {'Content-Type': 'application/x-www-form-urlencoded'},
+ url: ACCESS_TOKEN_URL,
+ data: "client_id=" + clientId + "&redirect_uri=" + redirect_uri + "&client_secret=" + clientSecret + "&code=" + code
+ })
+ .success(function (res) {
+ deferred.resolve(res);
+ }).error(function (data, status) {
+ deferred.reject("Problem authenticating " );
+ }).finally(function () {
+ setTimeout(function () {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function (event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ dribble.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.dropbox', ['oauth.utils'])
+ .factory('$ngCordovaDropbox', dropbox);
+
+ function dropbox($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthDropbox };
+
+ /*
+ * Sign into the Dropbox service
+ *
+ * @param string appKey
+ * @param object options
+ * @return promise
+ */
+ function oauthDropbox(appKey, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open("https://www.dropbox.com/1/oauth2/authorize?client_id=" + appKey + "&redirect_uri=" + redirect_uri + "&response_type=token", "_blank", "location=no,clearsessioncache=yes,clearcache=yes");
+ browserRef.addEventListener("loadstart", function(event) {
+ if ((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, token_type: parameterMap.token_type, uid: parameterMap.uid });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ dropbox.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.envato', ['oauth.utils'])
+ .factory('$ngCordovaEnvato', envato);
+
+ function envato($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthEnvato };
+
+ /*
+ * Sign into the Envato service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthEnvato(clientId, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://api.envato.com/authorization?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ envato.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.facebook', ['oauth.utils'])
+ .factory('$ngCordovaFacebook', facebook);
+
+ function facebook($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthFacebook };
+
+ /*
+ * Sign into the Facebook service
+ *
+ * @param string clientId
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthFacebook(clientId, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var flowUrl = "https://www.facebook.com/v2.6/dialog/oauth?client_id=" + clientId + "&redirect_uri=" + redirect_uri + "&response_type=token&scope=" + appScope.join(",");
+ if(options !== undefined && options.hasOwnProperty("auth_type")) {
+ flowUrl += "&auth_type=" + options.auth_type;
+ }
+ var browserRef = window.cordova.InAppBrowser.open(flowUrl, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in });
+ } else {
+ if ((event.url).indexOf("error_code=100") !== 0) {
+ deferred.reject("Facebook returned error_code=100: Invalid permissions");
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ facebook.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.familySearch', ['oauth.utils'])
+ .factory('$ngCordovaFamilySearch', familySearch);
+
+ function familySearch($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthFamilySearch };
+
+ /*
+ * Sign into the FamilySearch service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthFamilySearch(clientId, state, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open("https://ident.familysearch.org/cis-web/oauth2/v3/authorization?client_id=" + clientId + "&redirect_uri=" + redirect_uri + "&response_type=code&state=" + state, "_blank", "location=no,clearsessioncache=yes,clearcache=yes");
+ browserRef.addEventListener("loadstart", function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, url: "https://ident.familysearch.org/cis-web/oauth2/v3/token", data: "client_id=" + clientId + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ familySearch.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.foursquare', ['oauth.utils'])
+ .factory('$ngCordovaFoursquare', foursquare);
+
+ function foursquare($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthFoursquare };
+
+ /*
+ * Sign into the Foursquare service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthFoursquare(clientId, options) {
+ var deferred = $q.defer();
+ if (window.cordova) {
+ if ($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://foursquare.com/oauth2/authenticate?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function (event) {
+ if ((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for (var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ var promiseResponse = {
+ access_token: parameterMap.access_token,
+ expires_in: parameterMap.expires_in
+ };
+ deferred.resolve(promiseResponse);
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ foursquare.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.github', ['oauth.utils'])
+ .factory('$ngCordovaGithub', github);
+
+ function github($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthGithub };
+
+ /*
+ * Sign into the GitHub service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthGithub(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://github.com/login/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope.join(","), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded', 'accept': 'application/json'}, url: "https://github.com/login/oauth/access_token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ github.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.google', ['oauth.utils'])
+ .factory('$ngCordovaGoogle', google);
+
+ function google($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthGoogle };
+
+ /*
+ * Sign into the Google service
+ *
+ * @param string clientId
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthGoogle(clientId, appScope, options) {
+ var deferred = $q.defer();
+ deferred.reject("Google no longer supports authentication requests from the web view. More information can be found at https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html");
+ return deferred.promise;
+ }
+ }
+
+ google.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.imgur', ['oauth.utils'])
+ .factory('$ngCordovaImgur', imgur);
+
+ function imgur($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthImgur };
+
+ /*
+ * Sign into the Imgur service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthImgur(clientId, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://api.imgur.com/oauth2/authorize?client_id=' + clientId + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in, account_username: parameterMap.account_username });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ imgur.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.instagram', ['oauth.utils'])
+ .factory('$ngCordovaInstagram', instagram);
+
+ function instagram($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthInstagram };
+
+ /*
+ * Sign into the Instagram service
+ *
+ * @param string clientId
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthInstagram(clientId, appScope, options) {
+ var deferred = $q.defer();
+ var split_tokens = {
+ 'code':'?',
+ 'token':'#'
+ };
+
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ var response_type = "token";
+ var instagramUrl = 'https://www.instagram.com/';
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ if(options.hasOwnProperty("response_type")) {
+ response_type = options.response_type;
+ }
+ }
+
+ var scope = '';
+ if (appScope && appScope.length > 0) {
+ scope = '&scope=' + appScope.join('+');
+ }
+
+ var url='https://api.instagram.com/oauth/authorize/?client_id=' + clientId + scope + '&response_type=' + response_type + '&redirect_uri=' + redirect_uri;
+ var browserRef = window.cordova.InAppBrowser.open(url, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split(split_tokens[response_type])[1];
+ var parameterMap = $cordovaOauthUtility.parseResponseParameters(callbackResponse);
+ if(parameterMap.access_token) {
+ deferred.resolve({ access_token: parameterMap.access_token });
+ } else if(parameterMap.code !== undefined && parameterMap.code !== null) {
+ deferred.resolve({ code: parameterMap.code });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ } else if ((event.url)===instagramUrl) {
+ browserRef.executeScript({
+ code: "window.location = '"+url+"';"
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ instagram.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.jawbone', ['oauth.utils'])
+ .factory('$ngCordovaJawbone', jawbone);
+
+ function jawbone($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthJawbone };
+
+ /*
+ * Sign into the Jawbone service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthJawbone(clientId,clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://jawbone.com/auth/oauth2/auth?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=code&scope=' + appScope.join(" "), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, url: "https://jawbone.com/auth/oauth2/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&grant_type=authorization_code&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ jawbone.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module("oauth.providers", [
+ "oauth.utils",
+ "oauth.500px",
+ "oauth.azuread",
+ "oauth.adfs",
+ 'oauth.dropbox',
+ 'oauth.digitalOcean',
+ 'oauth.google',
+ 'oauth.github',
+ 'oauth.facebook',
+ 'oauth.linkedin',
+ 'oauth.instagram',
+ 'oauth.box',
+ 'oauth.reddit',
+ 'oauth.slack',
+ 'oauth.twitter',
+ 'oauth.meetup',
+ 'oauth.salesforce',
+ 'oauth.strava',
+ 'oauth.withings',
+ 'oauth.foursquare',
+ 'oauth.magento',
+ 'oauth.vkontakte',
+ 'oauth.odnoklassniki',
+ 'oauth.imgur',
+ 'oauth.spotify',
+ 'oauth.uber',
+ 'oauth.windowslive',
+ 'oauth.yammer',
+ 'oauth.venmo',
+ 'oauth.stripe',
+ 'oauth.rally',
+ 'oauth.familySearch',
+ 'oauth.envato',
+ 'oauth.weibo',
+ 'oauth.jawbone',
+ 'oauth.untappd',
+ 'oauth.dribble',
+ 'oauth.pocket',
+ 'oauth.mercadolibre',
+ 'oauth.xing',
+ 'oauth.netatmo',
+ 'oauth.trakttv',
+ 'oauth.yahoo'])
+ .factory("$cordovaOauth", cordovaOauth);
+
+ function cordovaOauth(
+ $q, $http, $cordovaOauthUtility, $ngCordovaAzureAD, $ngCordovaAdfs, $ngCordovaDropbox, $ngCordovaDigitalOcean,
+ $ngCordovaGoogle, $ngCordovaGithub, $ngCordovaFacebook, $ngCordovaLinkedin, $ngCordovaInstagram, $ngCordovaBox, $ngCordovaReddit, $ngCordovaSlack,
+ $ngCordovaTwitter, $ngCordovaMeetup, $ngCordovaSalesforce, $ngCordovaStrava, $ngCordovaWithings, $ngCordovaFoursquare, $ngCordovaMagento,
+ $ngCordovaVkontakte, $ngCordovaOdnoklassniki, $ngCordovaImgur, $ngCordovaSpotify, $ngCordovaUber, $ngCordovaWindowslive, $ngCordovaYammer,
+ $ngCordovaVenmo, $ngCordovaStripe, $ngCordovaRally, $ngCordovaFamilySearch, $ngCordovaEnvato, $ngCordovaWeibo, $ngCordovaJawbone, $ngCordovaUntappd,
+ $ngCordovaDribble, $ngCordovaPocket, $ngCordovaMercadolibre, $ngCordovaXing, $ngCordovaNetatmo, $ngCordovaTraktTv, $ngCordovaYahoo) {
+
+ return {
+ azureAD: $ngCordovaAzureAD.signin,
+ adfs: $ngCordovaAdfs.signin,
+ dropbox: $ngCordovaDropbox.signin,
+ digitalOcean: $ngCordovaDigitalOcean.signin,
+ google: $ngCordovaGoogle.signin,
+ github: $ngCordovaGithub.signin,
+ facebook: $ngCordovaFacebook.signin,
+ linkedin: $ngCordovaLinkedin.signin,
+ instagram: $ngCordovaInstagram.signin,
+ box: $ngCordovaBox.signin,
+ reddit: $ngCordovaReddit.signin,
+ slack: $ngCordovaSlack.signin,
+ twitter: $ngCordovaTwitter.signin,
+ meetup: $ngCordovaMeetup.signin,
+ salesforce: $ngCordovaSalesforce.signin,
+ strava: $ngCordovaStrava.signin,
+ withings: $ngCordovaWithings.signin,
+ foursquare: $ngCordovaFoursquare.signin,
+ magento: $ngCordovaMagento.signin,
+ vkontakte: $ngCordovaVkontakte.signin,
+ odnoklassniki: $ngCordovaOdnoklassniki.signin,
+ imgur: $ngCordovaImgur.signin,
+ spotify: $ngCordovaSpotify.signin,
+ uber: $ngCordovaUber.signin,
+ windowsLive: $ngCordovaWindowslive.signin,
+ yammer: $ngCordovaYammer.signin,
+ venmo: $ngCordovaVenmo.signin,
+ stripe: $ngCordovaStripe.signin,
+ rally: $ngCordovaRally.signin,
+ familySearch: $ngCordovaFamilySearch.signin,
+ envato: $ngCordovaEnvato.signin,
+ weibo: $ngCordovaWeibo.signin,
+ jawbone: $ngCordovaJawbone.signin,
+ untappd: $ngCordovaUntappd.signin,
+ dribble: $ngCordovaDribble.signin,
+ pocket: $ngCordovaPocket.signin,
+ mercadolibre: $ngCordovaMercadolibre.signin,
+ xing: $ngCordovaXing.signin,
+ netatmo: $ngCordovaNetatmo.signin,
+ trakttv: $ngCordovaTraktTv.signin,
+ yahoo: $ngCordovaYahoo.signin
+ };
+ }
+
+ cordovaOauth.$inject = [
+ "$q", '$http', "$cordovaOauthUtility",
+ "$ngCordovaAzureAD",
+ "$ngCordovaAdfs",
+ '$ngCordovaDropbox',
+ '$ngCordovaDigitalOcean',
+ '$ngCordovaGoogle',
+ '$ngCordovaGithub',
+ '$ngCordovaFacebook',
+ '$ngCordovaLinkedin',
+ '$ngCordovaInstagram',
+ '$ngCordovaBox',
+ '$ngCordovaReddit',
+ '$ngCordovaSlack',
+ '$ngCordovaTwitter',
+ '$ngCordovaMeetup',
+ '$ngCordovaSalesforce',
+ '$ngCordovaStrava',
+ '$ngCordovaWithings',
+ '$ngCordovaFoursquare',
+ '$ngCordovaMagento',
+ '$ngCordovaVkontakte',
+ '$ngCordovaOdnoklassniki',
+ '$ngCordovaImgur',
+ '$ngCordovaSpotify',
+ '$ngCordovaUber',
+ '$ngCordovaWindowslive',
+ '$ngCordovaYammer',
+ '$ngCordovaVenmo',
+ '$ngCordovaStripe',
+ '$ngCordovaRally',
+ '$ngCordovaFamilySearch',
+ '$ngCordovaEnvato',
+ '$ngCordovaWeibo',
+ '$ngCordovaJawbone',
+ '$ngCordovaUntappd',
+ '$ngCordovaDribble',
+ '$ngCordovaPocket',
+ '$ngCordovaMercadolibre',
+ '$ngCordovaXing',
+ '$ngCordovaNetatmo',
+ '$ngCordovaTraktTv',
+ '$ngCordovaYahoo'
+ ];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.linkedin', ['oauth.utils'])
+ .factory('$ngCordovaLinkedin', linkedin);
+
+ function linkedin($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthLinkedin };
+
+ /*
+ * Sign into the LinkedIn service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param string state
+ * @param object options
+ * @return promise
+ */
+ function oauthLinkedin(clientId, clientSecret, appScope, state, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://www.linkedin.com/uas/oauth2/authorization?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope.join(" ") + '&response_type=code&state=' + state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ try {
+ var requestToken = (event.url).split("code=")[1].split("&")[0];
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, url: "https://www.linkedin.com/uas/oauth2/accessToken", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }catch(e){
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ linkedin.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.magento', ['oauth.utils'])
+ .factory('$ngCordovaMagento', magento);
+
+ function magento($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthMagento };
+
+ /*
+ * Sign into the Magento service
+ * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures
+ *
+ * @param string baseUrl
+ * @param string clientId
+ * @param string clientSecret
+ * @return promise
+ */
+ function oauthMagento(baseUrl, clientId, clientSecret) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ if(typeof jsSHA !== "undefined") {
+ var oauthObject = {
+ oauth_callback: "http://localhost/callback",
+ oauth_consumer_key: clientId,
+ oauth_nonce: $cordovaOauthUtility.createNonce(5),
+ oauth_signature_method: "HMAC-SHA1",
+ oauth_timestamp: Math.round((new Date()).getTime() / 1000.0),
+ oauth_version: "1.0"
+ };
+ var signatureObj = $cordovaOauthUtility.createSignature("POST", baseUrl + "/oauth/initiate", oauthObject, { oauth_callback: "http://localhost/callback" }, clientSecret);
+ $http.defaults.headers.post.Authorization = signatureObj.authorization_header;
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: baseUrl + "/oauth/initiate", data: "oauth_callback=http://localhost/callback" })
+ .success(function(requestTokenResult) {
+ var requestTokenParameters = (requestTokenResult).split("&");
+ var parameterMap = {};
+
+ for(var i = 0; i < requestTokenParameters.length; i++) {
+ parameterMap[requestTokenParameters[i].split("=")[0]] = requestTokenParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.hasOwnProperty("oauth_token") === false) {
+ deferred.reject("Oauth request token was not received");
+ }
+
+ var tokenSecret = parameterMap.oauth_token_secret;
+ var browserRef = window.cordova.InAppBrowser.open(baseUrl + '/oauth/authorize?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+
+ browserRef.addEventListener('loadstart', function(event) {
+ if ((event.url).indexOf("http://localhost/callback") === 0) {
+ var callbackResponse = (event.url).split("?")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.hasOwnProperty("oauth_verifier") === false) {
+ deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned");
+ }
+ delete oauthObject.oauth_signature;
+ delete oauthObject.oauth_callback;
+ oauthObject.oauth_token = parameterMap.oauth_token;
+ oauthObject.oauth_nonce = $cordovaOauthUtility.createNonce(5);
+ oauthObject.oauth_verifier = parameterMap.oauth_verifier;
+ var signatureObj = $cordovaOauthUtility.createSignature("POST", baseUrl + "/oauth/token", oauthObject, {}, clientSecret, tokenSecret);
+ $http.defaults.headers.post.Authorization = signatureObj.authorization_header;
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: baseUrl + "/oauth/token" })
+ .success(function(result) {
+ var accessTokenParameters = result.split("&");
+ var parameterMap = {};
+ for(var i = 0; i < accessTokenParameters.length; i++) {
+ parameterMap[accessTokenParameters[i].split("=")[0]] = accessTokenParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.hasOwnProperty("oauth_token_secret") === false) {
+ deferred.reject("Oauth access token was not received");
+ }
+
+ deferred.resolve(parameterMap);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+ } else {
+ deferred.reject("Missing jsSHA JavaScript library");
+ }
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ magento.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.meetup', ['oauth.utils'])
+ .factory('$ngCordovaMeetup', meetup);
+
+ function meetup($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthMeetup };
+
+ /*
+ * Sign into the Meetup service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthMeetup(clientId, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://secure.meetup.com/oauth2/authorize/?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve(parameterMap);
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ meetup.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.mercadolibre', ['oauth.utils'])
+ .factory('$ngCordovaMercadolibre', mercadolibre);
+
+ function mercadolibre($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthMercadolibre };
+
+ /*
+ * Sign into the Mercadolibre service
+ *
+ * @param string appId
+ * @param object options
+ * @return promise
+ */
+ function oauthMercadolibre(appId, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open("http://auth.mercadolibre.com.ar/authorization?client_id=" + appId + "&redirect_uri=" + redirect_uri + "&response_type=token", "_blank", "location=no,clearsessioncache=yes,clearcache=yes");
+ browserRef.addEventListener("loadstart", function(event) {
+ if ((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in, user_id: parameterMap.user_id, domains: parameterMap.domains });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ mercadolibre.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.netatmo', ['oauth.utils']).factory('$ngCordovaNetatmo', netatmo);
+
+ function netatmo($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthNetatmo };
+
+ /*
+ * Sign into the Netatmo service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthNetatmo(options) {
+
+ var deferred = $q.defer();
+ var fetchingToken = false;
+ var clientId = (options.clientId)? options.clientId: null;
+ var clientSecret = (options.clientSecret)? options.clientSecret: null;
+ var appScope = (options.appScope)? options.appScope: null;
+ var state = (options.state)? options.state: Math.random().toString(36).substr(2, 5);
+ var inappbrowserOptions = (options.inappbrowserOptions)? options.inappbrowserOptions: 'location=no,clearsessioncache=yes,clearcache=yes';
+
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+
+ var redirect_uri = "http://localhost/callback";
+ var authorize_uri = 'https://api.netatmo.com/oauth2/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope +'&state='+ state;
+ var browserRef = window.cordova.InAppBrowser.open(authorize_uri, '_blank', inappbrowserOptions);
+
+ browserRef.addEventListener('loadstart', inappbrowserLoadStarted);
+ browserRef.addEventListener('exit', inapbrowserExited);
+ } else {
+ deferred.reject({error: "no_inappbrowser_plugin"});
+ }
+ } else {
+ deferred.reject({error: "no_inappbrowser_plugin"});
+ }
+
+ function inappbrowserLoadStarted(event){
+
+ var hasNoRedirectUri = (event.url).indexOf(redirect_uri) === 0;
+ var redirectUriMatch = (event.url).split("?")[0] === redirect_uri;
+
+ if(hasNoRedirectUri && redirectUriMatch) {
+
+ fetchingToken = true;
+ browserRef.close();
+
+ //get response url parameters
+ var callbackResponse = (event.url).split("?")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var urlParameters = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ urlParameters[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ var requestToken = urlParameters.code;
+ var responseState = urlParameters.state;
+
+ if(state === responseState){
+
+ var httpOptions = {
+ method: "post",
+ url: "https://api.netatmo.com/oauth2/token",
+ data: 'grant_type=authorization_code&client_id='+ clientId +'&client_secret='+ clientSecret +'&code='+ requestToken +'&scope='+ appScope +'&redirect_uri='+ redirect_uri,
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
+ },
+ };
+
+ $http(httpOptions).success(requestTokenSuccess).error(requestTokenError).finally(requestTokenFinally);
+ } else {
+ deferred.reject({error: "string_missmatch"});
+ }
+ }
+ function requestTokenSuccess(success){
+ deferred.resolve(success);
+ }
+ function requestTokenError(error){
+ deferred.reject(error);
+ }
+ function requestTokenFinally(){}
+ }
+ function inapbrowserExited(event){
+
+ if(!fetchingToken){
+
+ var error = {error: "flow_canceled"};
+ deferred.reject(error);
+ }
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ netatmo.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.odnoklassniki', ['oauth.utils'])
+ .factory('$ngCordovaOdnoklassniki', odnoklassniki);
+
+ function odnoklassniki($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthOdnoklassniki };
+
+ /*
+ * Sign into the Odnoklassniki service
+ *
+ * @param string clientId
+ * @param array appScope (for example: "VALUABLE_ACCESS ,GROUP_CONTENT,VIDEO_CONTENT")
+ * @return promise
+ */
+ function oauthOdnoklassniki(clientId, appScope) {
+ var deferred = $q.defer();
+ if (window.cordova) {
+ if ($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var browserRef = window.cordova.InAppBrowser.open('http://www.odnoklassniki.ru/oauth/authorize?client_id=' + clientId + '&scope=' + appScope.join(",") + '&response_type=token&redirect_uri=http://localhost/callback' + '&layout=m', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function (event) {
+ if ((event.url).indexOf("http://localhost/callback") === 0) {
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for (var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, session_secret_key: parameterMap.session_secret_key });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ setTimeout(function () {
+ browserRef.close();
+ }, 10);
+ }
+ });
+ browserRef.addEventListener('exit', function (event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ odnoklassniki.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.pocket', ['oauth.utils'])
+ .factory('$ngCordovaPocket', pocket);
+
+ function pocket($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthPocket };
+
+ /*
+ * Sign into the Pocket service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthPocket(clientId, options) {
+ var deferred = $q.defer();
+ if (window.cordova) {
+ if ($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_url = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_url")) {
+ redirect_url = options.redirect_url;
+ }
+ }
+
+ var data = "consumer_key=" + clientId + "&redirect_uri=" + encodeURIComponent(redirect_url);
+ $http({
+ method: "post",
+ url: "https://getpocket.com/v3/oauth/request",
+ headers: {
+ "X-Accept": "application/x-www-form-urlencoded",
+ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
+ },
+ data: data
+ })
+ .success(function(data) {
+ var code = data.split("code=")[1];
+ var browserRef = window.cordova.InAppBrowser.open('https://getpocket.com/auth/authorize?request_token=' + code + '&redirect_uri=' + redirect_url, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_url) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ data = "consumer_key=" + clientId + "&code=" + code;
+ $http({
+ method: "post",
+ url: "https://getpocket.com/v3/oauth/authorize",
+ headers: {
+ "X-Accept": "application/x-www-form-urlencoded",
+ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
+ },
+ data: data
+ })
+ .success(function(result) {
+ deferred.resolve(result);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ pocket.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.rally', ['oauth.utils'])
+ .factory('$ngCordovaRally', rally);
+
+ function rally($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthRally };
+
+ /*
+ * Sign into the Rally service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthRally(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://rally1.rallydev.com/login/oauth2/auth?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf("http://localhost/callback") === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://rally1.rallydev.com/login/oauth2/auth", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ rally.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.reddit', ['oauth.utils'])
+ .factory('$ngCordovaReddit', reddit);
+
+ function reddit($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthReddit };
+
+ /*
+ * Sign into the Reddit service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthReddit(clientId, clientSecret, appScope, compact, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://ssl.reddit.com/api/v1/authorize' + (compact ? '.compact' : '') + '?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&duration=permanent&state=ngcordovaoauth&scope=' + appScope.join(",") + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http.defaults.headers.post.Authorization = 'Basic ' + btoa(clientId + ":" + clientSecret);
+ $http({method: "post", url: "https://ssl.reddit.com/api/v1/access_token", data: "redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ reddit.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.salesforce', ['oauth.utils'])
+ .factory('$ngCordovaSalesforce', salesforce);
+
+ function salesforce($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthSalesforce };
+
+ /*
+ * Sign into the Salesforce service
+ *
+ * Suggestion: use salesforce oauth with forcetk.js(as SDK)
+ *
+ * @param string loginUrl (such as: https://login.salesforce.com ; please notice community login)
+ * @param string clientId (copy from connection app info)
+ * @param string redirectUri (callback url in connection app info)
+ * @return promise
+ */
+ function oauthSalesforce(loginUrl, clientId) {
+ var redirectUri = 'http://localhost/callback';
+ var getAuthorizeUrl = function (loginUrl, clientId, redirectUri) {
+ return loginUrl+'services/oauth2/authorize?display=touch'+
+ '&response_type=token&client_id='+escape(clientId)+
+ '&redirect_uri='+escape(redirectUri);
+ };
+ var startWith = function(string, str) {
+ return (string.substr(0, str.length) === str);
+ };
+
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var browserRef = window.cordova.InAppBrowser.open(getAuthorizeUrl(loginUrl, clientId, redirectUri), "_blank", "location=no,clearsessioncache=yes,clearcache=yes");
+ browserRef.addEventListener("loadstart", function(event) {
+ if(startWith(event.url, redirectUri)) {
+ var oauthResponse = {};
+
+ var fragment = (event.url).split('#')[1];
+
+ if (fragment) {
+ var nvps = fragment.split('&');
+ for (var nvp in nvps) {
+ var parts = nvps[nvp].split('=');
+ oauthResponse[parts[0]] = unescape(parts[1]);
+ }
+ }
+
+ if (typeof oauthResponse === 'undefined' ||
+ typeof oauthResponse.access_token === 'undefined') {
+ deferred.reject("Problem authenticating");
+ } else {
+ deferred.resolve(oauthResponse);
+ }
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ salesforce.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.slack', ['oauth.utils'])
+ .factory('$ngCordovaSlack', slack);
+
+ function slack($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthSlack };
+
+ /*
+ * Sign into the Slack service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthSlack(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+
+ var browserRef = window.cordova.InAppBrowser.open('https://slack.com/oauth/authorize' + '?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&state=ngcordovaoauth&scope=' + appScope.join(","), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://slack.com/api/oauth.access", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ slack.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.spotify', ['oauth.utils'])
+ .factory('$ngCordovaSpotify', spotify);
+
+ function spotify($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthSpotify };
+
+ /*
+ * Sign into the Spotify service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthSpotify(clientId, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ var response_type = "token";
+ var state = "";
+ var show_dialog = "";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ if(options.hasOwnProperty("response_type")) {
+ response_type = options.response_type;
+ }
+ if(options.hasOwnProperty("state")) {
+ state = "&state=" + options.state;
+ }
+ if(options.hasOwnProperty("show_dialog")) {
+ show_dialog = "&show_dialog=" + options.show_dialog;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://accounts.spotify.com/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=' + response_type + state + '&scope=' + appScope.join(" ") + show_dialog, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var splitChar = (response_type === "code") ? "?" : "#";
+ var callbackResponse = (event.url).split(splitChar)[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(response_type === "token" && parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in, account_username: parameterMap.account_username });
+ } else if(response_type === "code" && parameterMap.code !== undefined && parameterMap.code !== null) {
+ deferred.resolve({ code: parameterMap.code, state: parameterMap.state });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ spotify.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.strava', ['oauth.utils'])
+ .factory('$ngCordovaStrava', strava);
+
+ function strava($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthStrava };
+
+ /*
+ * Sign into the Strava service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthStrava(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://www.strava.com/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope.join(",") + '&response_type=code&approval_prompt=force', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://www.strava.com/oauth/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ strava.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.stripe', ['oauth.utils'])
+ .factory('$ngCordovaStripe', stripe);
+
+ function stripe($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthStripe };
+
+ /*
+ * Sign into the Stripe service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthStripe(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://connect.stripe.com/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf("http://localhost/callback") === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://connect.stripe.com/oauth/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ stripe.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.trakttv', ['oauth.utils'])
+ .factory('$ngCordovaTraktTv', trakttv);
+
+ function trakttv($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthTraktTv };
+
+ /*
+ * Sign into the Trakt.tv service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string state
+ * @param object options
+ * @return promise
+ */
+ function oauthTraktTv(clientId, clientSecret, appScope, state, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://trakt.tv/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=code&state=' + state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ try {
+ var requestToken = (event.url).split("code=")[1].split("&")[0];
+ $http({method: "post", headers: {'Content-Type': 'application/json'}, url: "https://trakt.tv/oauth/token", data: {'code': requestToken, 'client_id': clientId, 'client_secret': clientSecret, 'redirect_uri': redirect_uri, 'grant_type': 'authorization_code'} })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }catch(e){
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ trakttv.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.twitter', ['oauth.utils'])
+ .factory('$ngCordovaTwitter', twitter);
+
+ function twitter($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthTwitter };
+
+ /*
+ * Sign into the Twitter service
+ * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @return promise
+ */
+ function oauthTwitter(clientId, clientSecret, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+
+ if(typeof jsSHA !== "undefined") {
+ var oauthObject = {
+ oauth_consumer_key: clientId,
+ oauth_nonce: $cordovaOauthUtility.createNonce(10),
+ oauth_signature_method: "HMAC-SHA1",
+ oauth_timestamp: Math.round((new Date()).getTime() / 1000.0),
+ oauth_version: "1.0"
+ };
+ var signatureObj = $cordovaOauthUtility.createSignature("POST", "https://api.twitter.com/oauth/request_token", oauthObject, { oauth_callback: redirect_uri }, clientSecret);
+ $http({
+ method: "post",
+ url: "https://api.twitter.com/oauth/request_token",
+ headers: {
+ "Authorization": signatureObj.authorization_header,
+ "Content-Type": "application/x-www-form-urlencoded"
+ },
+ data: "oauth_callback=" + encodeURIComponent(redirect_uri)
+ })
+ .success(function(requestTokenResult) {
+ var requestTokenParameters = (requestTokenResult).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < requestTokenParameters.length; i++) {
+ parameterMap[requestTokenParameters[i].split("=")[0]] = requestTokenParameters[i].split("=")[1];
+ }
+ if(parameterMap.hasOwnProperty("oauth_token") === false) {
+ deferred.reject("Oauth request token was not received");
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://api.twitter.com/oauth/authenticate?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var callbackResponse = (event.url).split("?")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.hasOwnProperty("oauth_verifier") === false) {
+ deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned");
+ }
+ delete oauthObject.oauth_signature;
+ oauthObject.oauth_token = parameterMap.oauth_token;
+ var signatureObj = $cordovaOauthUtility.createSignature("POST", "https://api.twitter.com/oauth/access_token", oauthObject, { oauth_verifier: parameterMap.oauth_verifier }, clientSecret);
+ $http({
+ method: "post",
+ url: "https://api.twitter.com/oauth/access_token",
+ headers: {
+ "Authorization": signatureObj.authorization_header
+ },
+ params: {
+ "oauth_verifier": parameterMap.oauth_verifier
+ }
+ })
+ .success(function(result) {
+ var accessTokenParameters = result.split("&");
+ var parameterMap = {};
+ for(var i = 0; i < accessTokenParameters.length; i++) {
+ parameterMap[accessTokenParameters[i].split("=")[0]] = accessTokenParameters[i].split("=")[1];
+ }
+ if(parameterMap.hasOwnProperty("oauth_token_secret") === false) {
+ deferred.reject("Oauth access token was not received");
+ }
+ deferred.resolve(parameterMap);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+ } else {
+ deferred.reject("Missing jsSHA JavaScript library");
+ }
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ twitter.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.uber', ['oauth.utils'])
+ .factory('$ngCordovaUber', uber);
+
+ function uber($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthUber };
+
+ /*
+ * Sign into the Uber service
+ *
+ * @param string clientId
+ * @param appScope array
+ * @param object options
+ * @return promise
+ */
+ function oauthUber(clientId, appScope, options) {
+
+ var deferred = $q.defer();
+ if(window.cordova) {
+
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://login.uber.com/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token&scope=' + appScope.join(" "), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, token_type: parameterMap.token_type, expires_in: parameterMap.expires_in, scope: parameterMap.scope });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+
+ }
+ }
+
+ uber.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.untappd', ['oauth.utils'])
+ .factory('$ngCordovaUntappd', untappd);
+
+ function untappd($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthUntappd };
+
+ /*
+ * Sign into the Untappd service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthUntappd(clientId, options) {
+ var deferred = $q.defer();
+ if (window.cordova) {
+ if ($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_url = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_url")) {
+ redirect_url = options.redirect_url;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://untappd.com/oauth/authenticate/?client_id=' + clientId + '&redirect_url=' + redirect_url + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function (event) {
+ if ((event.url).indexOf(redirect_url) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for (var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ var promiseResponse = {
+ access_token: parameterMap.access_token
+ };
+ deferred.resolve(promiseResponse);
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ untappd.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.venmo', ['oauth.utils'])
+ .factory('$ngCordovaVenmo', venmo);
+
+ function venmo($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthVenmo };
+
+ /*
+ * Sign into the Venmo service
+ *
+ * @param string clientId
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthVenmo(clientId, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://api.venmo.com/v1/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token&scope=' + appScope.join(" "), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("?")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token });
+ } else if(parameterMap.error !== undefined && parameterMap.error !== null) {
+ deferred.reject((parameterMap.error).replace("+", " "));
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ venmo.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.vkontakte', ['oauth.utils'])
+ .factory('$ngCordovaVkontakte', vkontakte);
+
+ function vkontakte($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthvKontakte };
+
+ /*
+ * Sign into the Vkontakte service
+ *
+ * @param string clientId
+ * @param array appScope (for example: "friends,wall,photos,messages")
+ * @return promise
+ */
+ function oauthvKontakte(clientId, appScope) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var browserRef = window.cordova.InAppBrowser.open('https://oauth.vk.com/authorize?client_id=' + clientId + '&redirect_uri=http://oauth.vk.com/blank.html&response_type=token&scope=' + appScope.join(",") + '&display=touch&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ var tmp = (event.url).split("#");
+ if (tmp[0] == 'https://oauth.vk.com/blank.html' || tmp[0] == 'http://oauth.vk.com/blank.html') {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ var output = { access_token: parameterMap.access_token, expires_in: parameterMap.expires_in };
+ if(parameterMap.email !== undefined && parameterMap.email !== null){
+ output.email = parameterMap.email;
+ }
+ deferred.resolve(output);
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ vkontakte.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.weibo', ['oauth.utils'])
+ .factory('$ngCordovaWeibo', weibo);
+
+ function weibo($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthWeibo };
+
+ /*
+ * Sign into the Weibo service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthWeibo(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var flowUrl = "https://open.weibo.cn/oauth2/authorize?display=mobile&client_id=" + clientId + "&redirect_uri=" + redirect_uri + "&scope=" + appScope.join(",");
+ if(options !== undefined) {
+ if(options.hasOwnProperty("language")) {
+ flowUrl += "&language=" + options.language;
+ }
+ if(options.hasOwnProperty("forcelogin")) {
+ flowUrl += "&forcelogin=" + options.forcelogin;
+ }
+ }
+
+ var browserRef = window.cordova.InAppBrowser.open(flowUrl, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://api.weibo.com/oauth2/access_token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&grant_type=authorization_code&code=" + requestToken + "&redirect_uri=" + redirect_uri})
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ weibo.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.windowslive', ['oauth.utils'])
+ .factory('$ngCordovaWindowslive', windowslive);
+
+ function windowslive($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthWindowslive };
+
+ /*
+ * Sign into the Windows Live Connect service
+ *
+ * @param string clientId
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthWindowslive(clientId, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "https://login.live.com/oauth20_desktop.srf";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://login.live.com/oauth20_authorize.srf?client_id=' + clientId + "&scope=" + appScope.join(",") + '&response_type=token&display=touch' + '&redirect_uri=' + redirect_uri, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function (event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit", function (event) { });
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for (var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function (event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ windowslive.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.withings', ['oauth.utils'])
+ .factory('$ngCordovaWithings', withings);
+
+ function withings($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthWithings };
+
+ /*
+ * Sign into the Withings service
+ * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @return promise
+ */
+ function oauthWithings(clientId, clientSecret) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ if(typeof jsSHA !== "undefined") {
+
+ // Step 1 : get a oAuth "request token"
+ var oauthObject = $cordovaOauthUtility.generateOauthParametersInstance(clientId);
+ oauthObject.oauth_callback = 'http://localhost/callback';
+
+ var requestTokenUrlBase = "https://oauth.withings.com/account/request_token";
+ var signatureObj = $cordovaOauthUtility.createSignature("GET", requestTokenUrlBase, {}, oauthObject, clientSecret);
+ oauthObject.oauth_signature = signatureObj.signature;
+
+ var requestTokenParameters = $cordovaOauthUtility.generateUrlParameters(oauthObject);
+
+ $http({method: "get", url: requestTokenUrlBase + "?" + requestTokenParameters })
+ .success(function(requestTokenResult) {
+
+ // Step 2 : End-user authorization
+ var parameterMap = $cordovaOauthUtility.parseResponseParameters(requestTokenResult);
+ if(!parameterMap.oauth_token) {
+ deferred.reject("Oauth request token was not received");
+ }
+ var oauthObject = $cordovaOauthUtility.generateOauthParametersInstance(clientId);
+ oauthObject.oauth_token = parameterMap.oauth_token;
+
+ // used in step 3
+ var oauthTokenSecret = parameterMap.oauth_token_secret;
+
+ var authorizeUrlBase = "https://oauth.withings.com/account/authorize";
+ var signatureObj = $cordovaOauthUtility.createSignature("GET", authorizeUrlBase, {}, oauthObject, clientSecret);
+ oauthObject.oauth_signature = signatureObj.signature;
+
+ var authorizeParameters = $cordovaOauthUtility.generateUrlParameters(oauthObject);
+ var browserRef = window.cordova.InAppBrowser.open(authorizeUrlBase + '?' + authorizeParameters, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+
+ // STEP 3: User Data Access token
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf("http://localhost/callback") === 0) {
+ var callbackResponse = (event.url).split("?")[1];
+ parameterMap = $cordovaOauthUtility.parseResponseParameters(callbackResponse);
+ if(!parameterMap.oauth_verifier) {
+ deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned");
+ }
+
+ var oauthObject = $cordovaOauthUtility.generateOauthParametersInstance(clientId);
+ oauthObject.oauth_token = parameterMap.oauth_token;
+
+ var accessTokenUrlBase = "https://oauth.withings.com/account/access_token";
+ var signatureObj = $cordovaOauthUtility.createSignature("GET", accessTokenUrlBase, {}, oauthObject, clientSecret, oauthTokenSecret);
+ oauthObject.oauth_signature = signatureObj.signature;
+
+ var accessTokenParameters = $cordovaOauthUtility.generateUrlParameters(oauthObject);
+
+ $http({method: "get", url: accessTokenUrlBase + '?' + accessTokenParameters})
+ .success(function(result) {
+ var parameterMap = $cordovaOauthUtility.parseResponseParameters(result);
+ if(!parameterMap.oauth_token_secret) {
+ deferred.reject("Oauth access token was not received");
+ }
+ deferred.resolve(parameterMap);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+ } else {
+ deferred.reject("Missing jsSHA JavaScript library");
+ }
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ withings.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.xing', ['oauth.utils'])
+ .factory('$ngCordovaXing', xing);
+
+ function xing($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthXing };
+
+ /*
+ * Sign into the Xing service
+ * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param object options
+ * @return promise
+ */
+ function oauthXing(clientId, clientSecret, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = 'http://localhost/callback';
+ if(options !== undefined) {
+ if(options.hasOwnProperty('redirect_uri')) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+
+ if(typeof jsSHA !== 'undefined') {
+ var oauthObject = {
+ oauth_consumer_key: clientId,
+ oauth_nonce: $cordovaOauthUtility.createNonce(10),
+ oauth_signature_method: 'HMAC-SHA1',
+ oauth_timestamp: Math.round((new Date()).getTime() / 1000.0),
+ oauth_version: '1.0'
+ };
+ var signatureObj = $cordovaOauthUtility.createSignature('POST', 'https://api.xing.com/v1/request_token', oauthObject, { oauth_callback: redirect_uri }, clientSecret);
+ $http({
+ method: 'post',
+ url: 'https://api.xing.com/v1/request_token',
+ headers: {
+ 'Authorization': signatureObj.authorization_header,
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ },
+ data: 'oauth_callback=' + encodeURIComponent(redirect_uri)
+ })
+ .success(function(requestTokenResult) {
+ var requestTokenParameters = (requestTokenResult).split('&');
+ var parameterMap = {};
+ for(var i = 0; i < requestTokenParameters.length; i++) {
+ parameterMap[requestTokenParameters[i].split('=')[0]] = requestTokenParameters[i].split('=')[1];
+ }
+ if(parameterMap.hasOwnProperty('oauth_token') === false) {
+ deferred.reject('Oauth request token was not received');
+ }
+ var oauthTokenSecret = parameterMap.oauth_token_secret;
+ var browserRef = window.cordova.InAppBrowser.open('https://api.xing.com/v1/authorize?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var callbackResponse = (event.url).split('?')[1];
+ var responseParameters = (callbackResponse).split('&');
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split('=')[0]] = responseParameters[i].split('=')[1];
+ }
+ if(parameterMap.hasOwnProperty('oauth_verifier') === false) {
+ deferred.reject('Browser authentication failed to complete. No oauth_verifier was returned');
+ }
+ delete oauthObject.oauth_signature;
+ oauthObject.oauth_token = parameterMap.oauth_token;
+ var signatureObj = $cordovaOauthUtility.createSignature('POST', 'https://api.xing.com/v1/access_token', oauthObject, { oauth_verifier: parameterMap.oauth_verifier }, clientSecret, oauthTokenSecret);
+ $http({
+ method: 'post',
+ url: 'https://api.xing.com/v1/access_token',
+ headers: {
+ 'Authorization': signatureObj.authorization_header
+ },
+ params: {
+ 'oauth_verifier': parameterMap.oauth_verifier
+ }
+ })
+ .success(function(result) {
+ var accessTokenParameters = result.split('&');
+ var parameterMap = {};
+ for(var i = 0; i < accessTokenParameters.length; i++) {
+ parameterMap[accessTokenParameters[i].split('=')[0]] = accessTokenParameters[i].split('=')[1];
+ }
+ if(parameterMap.hasOwnProperty('oauth_token_secret') === false) {
+ deferred.reject('Oauth access token was not received');
+ }
+ deferred.resolve(parameterMap);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject('The sign in flow was canceled');
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+ } else {
+ deferred.reject('Missing jsSHA JavaScript library');
+ }
+ } else {
+ deferred.reject('Could not find InAppBrowser plugin');
+ }
+ } else {
+ deferred.reject('Cannot authenticate via a web browser');
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ xing.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.yahoo', ['oauth.utils'])
+ .factory('$ngCordovaYahoo', yahoo);
+
+ function yahoo($q, $cordovaOauthUtility) {
+ return { signin: oauthYahoo };
+
+ /*
+ * Sign into the Yahoo service
+ *
+ * @param string clientId
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthYahoo(clientId, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+
+ var providerUrl = 'https://api.login.yahoo.com/oauth2/request_auth?client_id=' + clientId;
+ providerUrl += '&redirect_uri=' + redirect_uri;
+ providerUrl += '&response_type=token';
+ providerUrl += '&scope=' + appScope.join(" ");
+
+ var browserRef = window.cordova.InAppBrowser.open(
+ providerUrl,
+ '_blank',
+ 'location=no,clearsessioncache=yes,clearcache=yes'
+ );
+
+ browserRef.addEventListener("loadstart", function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({
+ access_token: parameterMap.access_token,
+ token_type: parameterMap.token_type,
+ expires_in: parameterMap.expires_in,
+ id_token: parameterMap.id_token
+ });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ yahoo.$inject = ['$q', '$cordovaOauthUtility'];
+})();
+
+(function() {
+ 'use strict';
+
+ angular.module('oauth.yammer', ['oauth.utils'])
+ .factory('$ngCordovaYammer', yammer);
+
+ function yammer($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthYammer };
+
+ /*
+ * Sign into the Yammer service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthYammer(clientId, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://www.yammer.com/dialog/oauth?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ yammer.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
+
+/*
+ * Cordova AngularJS Oauth
+ *
+ * Created by Nic Raboy
+ * http://www.nraboy.com
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Use Oauth sign in for various web services.
+ *
+ *
+ * REQUIRES:
+ *
+ * Apache Cordova 3.5+
+ * Apache InAppBrowser Plugin
+ * Apache Cordova Whitelist Plugin
+ *
+ *
+ * SUPPORTS:
+ *
+ * 500px
+ * Dropbox
+ * Digital Ocean
+ * Google
+ * GitHub
+ * Facebook
+ * LinkedIn
+ * Instagram
+ * Box
+ * Reddit
+ * Twitter
+ * Meetup
+ * Salesforce
+ * Strava
+ * Withings
+ * Foursquare
+ * Magento
+ * vkontakte
+ * Odnoklassniki
+ * ADFS
+ * Imgur
+ * Spotify
+ * Uber
+ * Windows Live Connect
+ * Yammer
+ * Venmo
+ * Stripe
+ * Rally
+ * Family Search
+ * Envato
+ * Slack
+ * Jawbone
+ * Untappd
+ * Xing
+ * Trakt.tv
+ */
+
+angular.module("ngCordovaOauth", [
+ "oauth.providers",
+ "oauth.utils"
+]);
+
+(function() {
+ angular.module("oauth.utils", [])
+ .factory("$cordovaOauthUtility", cordovaOauthUtility);
+
+ function cordovaOauthUtility($q) {
+ return {
+ isInAppBrowserInstalled: isInAppBrowserInstalled,
+ createSignature: createSignature,
+ createNonce: createNonce,
+ generateUrlParameters: generateUrlParameters,
+ parseResponseParameters: parseResponseParameters,
+ generateOauthParametersInstance: generateOauthParametersInstance
+ };
+
+ /*
+ * Check to see if the mandatory InAppBrowser plugin is installed
+ *
+ * @param
+ * @return boolean
+ */
+ function isInAppBrowserInstalled() {
+ var cordovaPluginList = cordova.require("cordova/plugin_list");
+ var inAppBrowserNames = ["cordova-plugin-inappbrowser", "cordova-plugin-inappbrowser.inappbrowser", "org.apache.cordova.inappbrowser"];
+
+ if (Object.keys(cordovaPluginList.metadata).length === 0) {
+ var formatedPluginList = cordovaPluginList.map(
+ function(plugin) {
+ return plugin.id || plugin.pluginId;
+ });
+
+ return inAppBrowserNames.some(function(name) {
+ return formatedPluginList.indexOf(name) != -1 ? true : false;
+ });
+ } else {
+ return inAppBrowserNames.some(function(name) {
+ return cordovaPluginList.metadata.hasOwnProperty(name);
+ });
+ }
+ }
+
+ /*
+ * Sign an Oauth 1.0 request
+ *
+ * @param string method
+ * @param string endPoint
+ * @param object headerParameters
+ * @param object bodyParameters
+ * @param string secretKey
+ * @param string tokenSecret (optional)
+ * @return object
+ */
+ function createSignature(method, endPoint, headerParameters, bodyParameters, secretKey, tokenSecret) {
+ if(typeof jsSHA !== "undefined") {
+ var headerAndBodyParameters = angular.copy(headerParameters);
+ var bodyParameterKeys = Object.keys(bodyParameters);
+
+ for(var i = 0; i < bodyParameterKeys.length; i++) {
+ headerAndBodyParameters[bodyParameterKeys[i]] = encodeURIComponent(bodyParameters[bodyParameterKeys[i]]);
+ }
+
+ var signatureBaseString = method + "&" + encodeURIComponent(endPoint) + "&";
+ var headerAndBodyParameterKeys = (Object.keys(headerAndBodyParameters)).sort();
+
+ for(i = 0; i < headerAndBodyParameterKeys.length; i++) {
+ if(i == headerAndBodyParameterKeys.length - 1) {
+ signatureBaseString += encodeURIComponent(headerAndBodyParameterKeys[i] + "=" + headerAndBodyParameters[headerAndBodyParameterKeys[i]]);
+ } else {
+ signatureBaseString += encodeURIComponent(headerAndBodyParameterKeys[i] + "=" + headerAndBodyParameters[headerAndBodyParameterKeys[i]] + "&");
+ }
+ }
+
+ var oauthSignatureObject = new jsSHA(signatureBaseString, "TEXT");
+
+ var encodedTokenSecret = '';
+ if (tokenSecret) {
+ encodedTokenSecret = encodeURIComponent(tokenSecret);
+ }
+
+ headerParameters.oauth_signature = encodeURIComponent(oauthSignatureObject.getHMAC(encodeURIComponent(secretKey) + "&" + encodedTokenSecret, "TEXT", "SHA-1", "B64"));
+ var headerParameterKeys = Object.keys(headerParameters);
+ var authorizationHeader = 'OAuth ';
+
+ for(i = 0; i < headerParameterKeys.length; i++) {
+ if(i == headerParameterKeys.length - 1) {
+ authorizationHeader += headerParameterKeys[i] + '="' + headerParameters[headerParameterKeys[i]] + '"';
+ } else {
+ authorizationHeader += headerParameterKeys[i] + '="' + headerParameters[headerParameterKeys[i]] + '",';
+ }
+ }
+
+ return { signature_base_string: signatureBaseString, authorization_header: authorizationHeader, signature: headerParameters.oauth_signature };
+ } else {
+ return "Missing jsSHA JavaScript library";
+ }
+ }
+
+ /*
+ * Create Random String Nonce
+ *
+ * @param integer length
+ * @return string
+ */
+ function createNonce(length) {
+ var text = "";
+ var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+
+ for(var i = 0; i < length; i++) {
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
+ }
+
+ return text;
+ }
+
+ function generateUrlParameters(parameters) {
+ var sortedKeys = Object.keys(parameters);
+ sortedKeys.sort();
+
+ var params = "";
+ var amp = "";
+
+ for (var i = 0 ; i < sortedKeys.length; i++) {
+ params += amp + sortedKeys[i] + "=" + parameters[sortedKeys[i]];
+ amp = "&";
+ }
+
+ return params;
+ }
+
+ function parseResponseParameters(response) {
+ if (response.split) {
+ var parameters = response.split("&");
+ var parameterMap = {};
+
+ for(var i = 0; i < parameters.length; i++) {
+ parameterMap[parameters[i].split("=")[0]] = parameters[i].split("=")[1];
+ }
+
+ return parameterMap;
+ }
+ else {
+ return {};
+ }
+ }
+
+ function generateOauthParametersInstance(consumerKey) {
+ var nonceObj = new jsSHA(Math.round((new Date()).getTime() / 1000.0), "TEXT");
+ var oauthObject = {
+ oauth_consumer_key: consumerKey,
+ oauth_nonce: nonceObj.getHash("SHA-1", "HEX"),
+ oauth_signature_method: "HMAC-SHA1",
+ oauth_timestamp: Math.round((new Date()).getTime() / 1000.0),
+ oauth_version: "1.0"
+ };
+ return oauthObject;
+ }
+ }
+
+ cordovaOauthUtility.$inject = ['$q'];
+})();
diff --git a/www/lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.js b/www/lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.js
new file mode 100644
index 0000000..cc19744
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.js
@@ -0,0 +1,4 @@
+// ng-cordova-oauth - v0.3.0 (2016-11-17)
+// http://www.nraboy.com
+!function(){"use strict";function a(a,b,c){function d(b,d){var e=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled()){var f="http://localhost/callback";void 0!==d&&d.hasOwnProperty("redirect_uri")&&(f=d.redirect_uri);var g=window.cordova.InAppBrowser.open("https://api.500px.com/v1/api/js-sdk/authorize?sdk_key="+b+"&callback="+f,"_blank","toolbar=no,zoom=no,location=no,clearsessioncache=yes,clearcache=yes");g.addEventListener("loadstart",function(a){if(0===a.url.indexOf(f)){var b=a.url.split("#token:")[1].split(",")[0];e.resolve({error:!1,success:!0,access_token:b,callback:f})}else e.reject({success:!1,callback:f,error:!0,access_token:null})}),g.addEventListener("exit",function(a){e.reject("The sign in flow was canceled")})}else e.reject("Could not find InAppBrowser plugin");else e.reject("Cannot authenticate via a web browser");return e.promise}return{signin:d}}angular.module("oauth.500px",["oauth.utils"]).factory("$ngCordova500px",a),a.$inject=["$q","$http","$cordovaOauthUtility"]}(),function(){"use strict";function a(a,b,c){function d(d,e,f){var g=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled()){var h=window.cordova.InAppBrowser.open(e+"/adfs/oauth2/authorize?response_type=code&client_id="+d+"&redirect_uri=http://localhost/callback&resource="+f,"_blank","location=no");h.addEventListener("loadstart",function(a){if(0===a.url.indexOf("http://localhost/callback")){var c=a.url.split("code=")[1];b({method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},url:e+"/adfs/oauth2/token",data:"client_id="+d+"&code="+c+"&redirect_uri=http://localhost/callback&grant_type=authorization_code"}).success(function(a){g.resolve(a)}).error(function(a,b){g.reject("Problem authenticating")})["finally"](function(){setTimeout(function(){h.close()},10)})}}),h.addEventListener("exit",function(a){g.reject("The sign in flow was canceled")})}else g.reject("Could not find InAppBrowser plugin");else g.reject("Cannot authenticate via a web browser");return g.promise}return{signin:d}}angular.module("oauth.adfs",["oauth.utils"]).factory("$ngCordovaAdfs",a),a.$inject=["$q","$http","$cordovaOauthUtility"]}(),function(){"use strict";function a(a,b,c){function d(d,e,f){var g=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled()){var h=window.cordova.InAppBrowser.open("https://login.microsoftonline.com/"+e+"/oauth2/authorize?response_type=code&client_id="+d+"&redirect_uri=http://localhost/callback","_blank","location=no,clearsessioncache=yes,clearcache=yes");h.addEventListener("loadstart",function(a){if(0===a.url.indexOf("http://localhost/callback")){var c=a.url.split("code=")[1];console.log(c),b({method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},url:"https://login.microsoftonline.com/"+e+"/oauth2/token",data:"client_id="+d+"&code="+c+"&redirect_uri=http://localhost/callback&grant_type=authorization_code&resource="+f}).success(function(a){g.resolve(a)}).error(function(a,b){g.reject("Problem authenticating")})["finally"](function(){setTimeout(function(){h.close()},10)})}}),h.addEventListener("exit",function(a){g.reject("The sign in flow was canceled")})}else g.reject("Could not find InAppBrowser plugin");else g.reject("Cannot authenticate via a web browser");return g.promise}return{signin:d}}angular.module("oauth.azuread",["oauth.utils"]).factory("$ngCordovaAzureAD",a),a.$inject=["$q","$http","$cordovaOauthUtility"]}(),function(){"use strict";function a(a,b,c){function d(d,e,f,g){var h=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled()){var i="http://localhost/callback";void 0!==g&&g.hasOwnProperty("redirect_uri")&&(i=g.redirect_uri);var j=window.cordova.InAppBrowser.open("https://app.box.com/api/oauth2/authorize/?client_id="+d+"&redirect_uri="+i+"&state="+f+"&response_type=code","_blank","location=no,clearsessioncache=yes,clearcache=yes");j.addEventListener("loadstart",function(a){if(0===a.url.indexOf(i)){var c=a.url.split("code=")[1];b({method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},url:"https://app.box.com/api/oauth2/token",data:"client_id="+d+"&client_secret="+e+"&redirect_uri="+i+"&grant_type=authorization_code&code="+c}).success(function(a){h.resolve(a)}).error(function(a,b){h.reject("Problem authenticating")})["finally"](function(){setTimeout(function(){j.close()},10)})}}),j.addEventListener("exit",function(a){h.reject("The sign in flow was canceled")})}else h.reject("Could not find InAppBrowser plugin");else h.reject("Cannot authenticate via a web browser");return h.promise}return{signin:d}}angular.module("oauth.box",["oauth.utils"]).factory("$ngCordovaBox",a),a.$inject=["$q","$http","$cordovaOauthUtility"]}(),function(){"use strict";function a(a,b,c){function d(d,e,f){var g=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled()){var h="http://localhost/callback";void 0!==f&&f.hasOwnProperty("redirect_uri")&&(h=f.redirect_uri);var i=window.cordova.InAppBrowser.open("https://cloud.digitalocean.com/v1/oauth/authorize?client_id="+d+"&redirect_uri="+h+"&response_type=code&scope=read%20write","_blank","location=no,clearsessioncache=yes,clearcache=yes");i.addEventListener("loadstart",function(a){if(0===a.url.indexOf(h)){var c=a.url.split("code=")[1];b({method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},url:"https://cloud.digitalocean.com/v1/oauth/token",data:"client_id="+d+"&client_secret="+e+"&redirect_uri="+h+"&grant_type=authorization_code&code="+c}).success(function(a){g.resolve(a)}).error(function(a,b){g.reject("Problem authenticating")})["finally"](function(){setTimeout(function(){i.close()},10)})}}),i.addEventListener("exit",function(a){g.reject("The sign in flow was canceled")})}else g.reject("Could not find InAppBrowser plugin");else g.reject("Cannot authenticate via a web browser");return g.promise}return{signin:d}}angular.module("oauth.digitalOcean",["oauth.utils"]).factory("$ngCordovaDigitalOcean",a),a.$inject=["$q","$http","$cordovaOauthUtility"]}(),function(){"use strict";function a(a,b,c){function d(d,e,f,g,h){var i=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled()){var j="http://localhost/callback",k="https://dribbble.com/oauth/authorize",l="https://dribbble.com/oauth/token";void 0!==g&&g.hasOwnProperty("redirect_uri")&&(j=g.redirect_uri),void 0===h&&(h=c.createNonce(5));var m=f.join(",").replace(/,/g,"+"),n=window.cordova.InAppBrowser.open(k+"?client_id="+d+"&redirect_uri="+j+"&scope="+m+"&state="+h,"_blank","location=no,clearsessioncache=yes,clearcache=yes");n.addEventListener("loadstart",function(a){if(0===a.url.indexOf(j)){var c=a.url.split("code=")[1],f=c.split("&")[0];b({method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},url:l,data:"client_id="+d+"&redirect_uri="+j+"&client_secret="+e+"&code="+f}).success(function(a){i.resolve(a)}).error(function(a,b){i.reject("Problem authenticating ")})["finally"](function(){setTimeout(function(){n.close()},10)})}}),n.addEventListener("exit",function(a){i.reject("The sign in flow was canceled")})}else i.reject("Could not find InAppBrowser plugin");else i.reject("Cannot authenticate via a web browser");return i.promise}return{signin:d}}angular.module("oauth.dribble",["oauth.utils"]).factory("$ngCordovaDribble",a),a.$inject=["$q","$http","$cordovaOauthUtility"]}(),function(){"use strict";function a(a,b,c){function d(b,d){var e=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled()){var f="http://localhost/callback";void 0!==d&&d.hasOwnProperty("redirect_uri")&&(f=d.redirect_uri);var g=window.cordova.InAppBrowser.open("https://www.dropbox.com/1/oauth2/authorize?client_id="+b+"&redirect_uri="+f+"&response_type=token","_blank","location=no,clearsessioncache=yes,clearcache=yes");g.addEventListener("loadstart",function(a){if(0===a.url.indexOf(f)){g.removeEventListener("exit",function(a){}),g.close();for(var b=a.url.split("#")[1],c=b.split("&"),d=[],h=0;h0&&(k="&scope="+d.join("+"));var l="https://api.instagram.com/oauth/authorize/?client_id="+b+k+"&response_type="+i+"&redirect_uri="+h,m=window.cordova.InAppBrowser.open(l,"_blank","location=no,clearsessioncache=yes,clearcache=yes");m.addEventListener("loadstart",function(a){if(0===a.url.indexOf(h)){m.removeEventListener("exit",function(a){}),m.close();var b=a.url.split(g[i])[1],d=c.parseResponseParameters(b);d.access_token?f.resolve({access_token:d.access_token}):void 0!==d.code&&null!==d.code?f.resolve({code:d.code}):f.reject("Problem authenticating")}else a.url===j&&m.executeScript({code:"window.location = '"+l+"';"})}),m.addEventListener("exit",function(a){f.reject("The sign in flow was canceled")})}else f.reject("Could not find InAppBrowser plugin");else f.reject("Cannot authenticate via a web browser");return f.promise}return{signin:d}}angular.module("oauth.instagram",["oauth.utils"]).factory("$ngCordovaInstagram",a),a.$inject=["$q","$http","$cordovaOauthUtility"]}(),function(){"use strict";function a(a,b,c){function d(d,e,f,g){var h=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled()){var i="http://localhost/callback";void 0!==g&&g.hasOwnProperty("redirect_uri")&&(i=g.redirect_uri);var j=window.cordova.InAppBrowser.open("https://jawbone.com/auth/oauth2/auth?client_id="+d+"&redirect_uri="+i+"&response_type=code&scope="+f.join(" "),"_blank","location=no,clearsessioncache=yes,clearcache=yes");j.addEventListener("loadstart",function(a){if(0===a.url.indexOf(i)){var c=a.url.split("code=")[1];b({method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},url:"https://jawbone.com/auth/oauth2/token",data:"client_id="+d+"&client_secret="+e+"&grant_type=authorization_code&code="+c}).success(function(a){h.resolve(a)}).error(function(a,b){h.reject("Problem authenticating")})["finally"](function(){setTimeout(function(){j.close()},10)})}}),j.addEventListener("exit",function(a){h.reject("The sign in flow was canceled")})}else h.reject("Could not find InAppBrowser plugin");else h.reject("Cannot authenticate via a web browser");return h.promise}return{signin:d}}angular.module("oauth.jawbone",["oauth.utils"]).factory("$ngCordovaJawbone",a),a.$inject=["$q","$http","$cordovaOauthUtility"]}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R){return{azureAD:d.signin,adfs:e.signin,dropbox:f.signin,digitalOcean:g.signin,google:h.signin,github:i.signin,facebook:j.signin,linkedin:k.signin,instagram:l.signin,box:m.signin,reddit:n.signin,slack:o.signin,twitter:p.signin,meetup:q.signin,salesforce:r.signin,strava:s.signin,withings:t.signin,foursquare:u.signin,magento:v.signin,vkontakte:w.signin,odnoklassniki:x.signin,imgur:y.signin,spotify:z.signin,uber:A.signin,windowsLive:B.signin,yammer:C.signin,venmo:D.signin,stripe:E.signin,rally:F.signin,familySearch:G.signin,envato:H.signin,weibo:I.signin,jawbone:J.signin,untappd:K.signin,dribble:L.signin,pocket:M.signin,mercadolibre:N.signin,xing:O.signin,netatmo:P.signin,trakttv:Q.signin,yahoo:R.signin}}angular.module("oauth.providers",["oauth.utils","oauth.500px","oauth.azuread","oauth.adfs","oauth.dropbox","oauth.digitalOcean","oauth.google","oauth.github","oauth.facebook","oauth.linkedin","oauth.instagram","oauth.box","oauth.reddit","oauth.slack","oauth.twitter","oauth.meetup","oauth.salesforce","oauth.strava","oauth.withings","oauth.foursquare","oauth.magento","oauth.vkontakte","oauth.odnoklassniki","oauth.imgur","oauth.spotify","oauth.uber","oauth.windowslive","oauth.yammer","oauth.venmo","oauth.stripe","oauth.rally","oauth.familySearch","oauth.envato","oauth.weibo","oauth.jawbone","oauth.untappd","oauth.dribble","oauth.pocket","oauth.mercadolibre","oauth.xing","oauth.netatmo","oauth.trakttv","oauth.yahoo"]).factory("$cordovaOauth",a),a.$inject=["$q","$http","$cordovaOauthUtility","$ngCordovaAzureAD","$ngCordovaAdfs","$ngCordovaDropbox","$ngCordovaDigitalOcean","$ngCordovaGoogle","$ngCordovaGithub","$ngCordovaFacebook","$ngCordovaLinkedin","$ngCordovaInstagram","$ngCordovaBox","$ngCordovaReddit","$ngCordovaSlack","$ngCordovaTwitter","$ngCordovaMeetup","$ngCordovaSalesforce","$ngCordovaStrava","$ngCordovaWithings","$ngCordovaFoursquare","$ngCordovaMagento","$ngCordovaVkontakte","$ngCordovaOdnoklassniki","$ngCordovaImgur","$ngCordovaSpotify","$ngCordovaUber","$ngCordovaWindowslive","$ngCordovaYammer","$ngCordovaVenmo","$ngCordovaStripe","$ngCordovaRally","$ngCordovaFamilySearch","$ngCordovaEnvato","$ngCordovaWeibo","$ngCordovaJawbone","$ngCordovaUntappd","$ngCordovaDribble","$ngCordovaPocket","$ngCordovaMercadolibre","$ngCordovaXing","$ngCordovaNetatmo","$ngCordovaTraktTv","$ngCordovaYahoo"]}(),function(){"use strict";function a(a,b,c){function d(d,e,f,g,h){var i=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled()){var j="http://localhost/callback";void 0!==h&&h.hasOwnProperty("redirect_uri")&&(j=h.redirect_uri);var k=window.cordova.InAppBrowser.open("https://www.linkedin.com/uas/oauth2/authorization?client_id="+d+"&redirect_uri="+j+"&scope="+f.join(" ")+"&response_type=code&state="+g,"_blank","location=no,clearsessioncache=yes,clearcache=yes");k.addEventListener("loadstart",function(a){if(0===a.url.indexOf(j))try{var c=a.url.split("code=")[1].split("&")[0];b({method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},url:"https://www.linkedin.com/uas/oauth2/accessToken",data:"client_id="+d+"&client_secret="+e+"&redirect_uri="+j+"&grant_type=authorization_code&code="+c}).success(function(a){i.resolve(a)}).error(function(a,b){i.reject("Problem authenticating")})["finally"](function(){setTimeout(function(){k.close()},10)})}catch(f){setTimeout(function(){k.close()},10)}}),k.addEventListener("exit",function(a){i.reject("The sign in flow was canceled")})}else i.reject("Could not find InAppBrowser plugin");else i.reject("Cannot authenticate via a web browser");return i.promise}return{signin:d}}angular.module("oauth.linkedin",["oauth.utils"]).factory("$ngCordovaLinkedin",a),a.$inject=["$q","$http","$cordovaOauthUtility"]}(),function(){"use strict";function a(a,b,c){function d(d,e,f){var g=a.defer();if(window.cordova)if(c.isInAppBrowserInstalled())if("undefined"!=typeof jsSHA){var h={oauth_callback:"http://localhost/callback",oauth_consumer_key:e,oauth_nonce:c.createNonce(5),oauth_signature_method:"HMAC-SHA1",oauth_timestamp:Math.round((new Date).getTime()/1e3),oauth_version:"1.0"},i=c.createSignature("POST",d+"/oauth/initiate",h,{oauth_callback:"http://localhost/callback"},f);b.defaults.headers.post.Authorization=i.authorization_header,b.defaults.headers.post["Content-Type"]="application/x-www-form-urlencoded",b({method:"post",url:d+"/oauth/initiate",data:"oauth_callback=http://localhost/callback"}).success(function(a){for(var e=a.split("&"),i={},j=0;j 0) {
+ scope = '&scope=' + appScope.join('+');
+ }
+
+ var url='https://api.instagram.com/oauth/authorize/?client_id=' + clientId + scope + '&response_type=' + response_type + '&redirect_uri=' + redirect_uri;
+ var browserRef = window.cordova.InAppBrowser.open(url, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split(split_tokens[response_type])[1];
+ var parameterMap = $cordovaOauthUtility.parseResponseParameters(callbackResponse);
+ if(parameterMap.access_token) {
+ deferred.resolve({ access_token: parameterMap.access_token });
+ } else if(parameterMap.code !== undefined && parameterMap.code !== null) {
+ deferred.resolve({ code: parameterMap.code });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ } else if ((event.url)===instagramUrl) {
+ browserRef.executeScript({
+ code: "window.location = '"+url+"';"
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ instagram.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.jawbone.js b/www/lib/ng-cordova-oauth/src/oauth.jawbone.js
new file mode 100644
index 0000000..32b36d4
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.jawbone.js
@@ -0,0 +1,65 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.jawbone', ['oauth.utils'])
+ .factory('$ngCordovaJawbone', jawbone);
+
+ function jawbone($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthJawbone };
+
+ /*
+ * Sign into the Jawbone service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthJawbone(clientId,clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://jawbone.com/auth/oauth2/auth?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=code&scope=' + appScope.join(" "), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, url: "https://jawbone.com/auth/oauth2/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&grant_type=authorization_code&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ jawbone.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.js b/www/lib/ng-cordova-oauth/src/oauth.js
new file mode 100644
index 0000000..60ab218
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.js
@@ -0,0 +1,147 @@
+(function() {
+ 'use strict';
+
+ angular.module("oauth.providers", [
+ "oauth.utils",
+ "oauth.500px",
+ "oauth.azuread",
+ "oauth.adfs",
+ 'oauth.dropbox',
+ 'oauth.digitalOcean',
+ 'oauth.google',
+ 'oauth.github',
+ 'oauth.facebook',
+ 'oauth.linkedin',
+ 'oauth.instagram',
+ 'oauth.box',
+ 'oauth.reddit',
+ 'oauth.slack',
+ 'oauth.twitter',
+ 'oauth.meetup',
+ 'oauth.salesforce',
+ 'oauth.strava',
+ 'oauth.withings',
+ 'oauth.foursquare',
+ 'oauth.magento',
+ 'oauth.vkontakte',
+ 'oauth.odnoklassniki',
+ 'oauth.imgur',
+ 'oauth.spotify',
+ 'oauth.uber',
+ 'oauth.windowslive',
+ 'oauth.yammer',
+ 'oauth.venmo',
+ 'oauth.stripe',
+ 'oauth.rally',
+ 'oauth.familySearch',
+ 'oauth.envato',
+ 'oauth.weibo',
+ 'oauth.jawbone',
+ 'oauth.untappd',
+ 'oauth.dribble',
+ 'oauth.pocket',
+ 'oauth.mercadolibre',
+ 'oauth.xing',
+ 'oauth.netatmo',
+ 'oauth.trakttv',
+ 'oauth.yahoo'])
+ .factory("$cordovaOauth", cordovaOauth);
+
+ function cordovaOauth(
+ $q, $http, $cordovaOauthUtility, $ngCordovaAzureAD, $ngCordovaAdfs, $ngCordovaDropbox, $ngCordovaDigitalOcean,
+ $ngCordovaGoogle, $ngCordovaGithub, $ngCordovaFacebook, $ngCordovaLinkedin, $ngCordovaInstagram, $ngCordovaBox, $ngCordovaReddit, $ngCordovaSlack,
+ $ngCordovaTwitter, $ngCordovaMeetup, $ngCordovaSalesforce, $ngCordovaStrava, $ngCordovaWithings, $ngCordovaFoursquare, $ngCordovaMagento,
+ $ngCordovaVkontakte, $ngCordovaOdnoklassniki, $ngCordovaImgur, $ngCordovaSpotify, $ngCordovaUber, $ngCordovaWindowslive, $ngCordovaYammer,
+ $ngCordovaVenmo, $ngCordovaStripe, $ngCordovaRally, $ngCordovaFamilySearch, $ngCordovaEnvato, $ngCordovaWeibo, $ngCordovaJawbone, $ngCordovaUntappd,
+ $ngCordovaDribble, $ngCordovaPocket, $ngCordovaMercadolibre, $ngCordovaXing, $ngCordovaNetatmo, $ngCordovaTraktTv, $ngCordovaYahoo) {
+
+ return {
+ azureAD: $ngCordovaAzureAD.signin,
+ adfs: $ngCordovaAdfs.signin,
+ dropbox: $ngCordovaDropbox.signin,
+ digitalOcean: $ngCordovaDigitalOcean.signin,
+ google: $ngCordovaGoogle.signin,
+ github: $ngCordovaGithub.signin,
+ facebook: $ngCordovaFacebook.signin,
+ linkedin: $ngCordovaLinkedin.signin,
+ instagram: $ngCordovaInstagram.signin,
+ box: $ngCordovaBox.signin,
+ reddit: $ngCordovaReddit.signin,
+ slack: $ngCordovaSlack.signin,
+ twitter: $ngCordovaTwitter.signin,
+ meetup: $ngCordovaMeetup.signin,
+ salesforce: $ngCordovaSalesforce.signin,
+ strava: $ngCordovaStrava.signin,
+ withings: $ngCordovaWithings.signin,
+ foursquare: $ngCordovaFoursquare.signin,
+ magento: $ngCordovaMagento.signin,
+ vkontakte: $ngCordovaVkontakte.signin,
+ odnoklassniki: $ngCordovaOdnoklassniki.signin,
+ imgur: $ngCordovaImgur.signin,
+ spotify: $ngCordovaSpotify.signin,
+ uber: $ngCordovaUber.signin,
+ windowsLive: $ngCordovaWindowslive.signin,
+ yammer: $ngCordovaYammer.signin,
+ venmo: $ngCordovaVenmo.signin,
+ stripe: $ngCordovaStripe.signin,
+ rally: $ngCordovaRally.signin,
+ familySearch: $ngCordovaFamilySearch.signin,
+ envato: $ngCordovaEnvato.signin,
+ weibo: $ngCordovaWeibo.signin,
+ jawbone: $ngCordovaJawbone.signin,
+ untappd: $ngCordovaUntappd.signin,
+ dribble: $ngCordovaDribble.signin,
+ pocket: $ngCordovaPocket.signin,
+ mercadolibre: $ngCordovaMercadolibre.signin,
+ xing: $ngCordovaXing.signin,
+ netatmo: $ngCordovaNetatmo.signin,
+ trakttv: $ngCordovaTraktTv.signin,
+ yahoo: $ngCordovaYahoo.signin
+ };
+ }
+
+ cordovaOauth.$inject = [
+ "$q", '$http', "$cordovaOauthUtility",
+ "$ngCordovaAzureAD",
+ "$ngCordovaAdfs",
+ '$ngCordovaDropbox',
+ '$ngCordovaDigitalOcean',
+ '$ngCordovaGoogle',
+ '$ngCordovaGithub',
+ '$ngCordovaFacebook',
+ '$ngCordovaLinkedin',
+ '$ngCordovaInstagram',
+ '$ngCordovaBox',
+ '$ngCordovaReddit',
+ '$ngCordovaSlack',
+ '$ngCordovaTwitter',
+ '$ngCordovaMeetup',
+ '$ngCordovaSalesforce',
+ '$ngCordovaStrava',
+ '$ngCordovaWithings',
+ '$ngCordovaFoursquare',
+ '$ngCordovaMagento',
+ '$ngCordovaVkontakte',
+ '$ngCordovaOdnoklassniki',
+ '$ngCordovaImgur',
+ '$ngCordovaSpotify',
+ '$ngCordovaUber',
+ '$ngCordovaWindowslive',
+ '$ngCordovaYammer',
+ '$ngCordovaVenmo',
+ '$ngCordovaStripe',
+ '$ngCordovaRally',
+ '$ngCordovaFamilySearch',
+ '$ngCordovaEnvato',
+ '$ngCordovaWeibo',
+ '$ngCordovaJawbone',
+ '$ngCordovaUntappd',
+ '$ngCordovaDribble',
+ '$ngCordovaPocket',
+ '$ngCordovaMercadolibre',
+ '$ngCordovaXing',
+ '$ngCordovaNetatmo',
+ '$ngCordovaTraktTv',
+ '$ngCordovaYahoo'
+ ];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.linkedin.js b/www/lib/ng-cordova-oauth/src/oauth.linkedin.js
new file mode 100644
index 0000000..d571e8e
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.linkedin.js
@@ -0,0 +1,68 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.linkedin', ['oauth.utils'])
+ .factory('$ngCordovaLinkedin', linkedin);
+
+ function linkedin($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthLinkedin };
+
+ /*
+ * Sign into the LinkedIn service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param string state
+ * @param object options
+ * @return promise
+ */
+ function oauthLinkedin(clientId, clientSecret, appScope, state, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://www.linkedin.com/uas/oauth2/authorization?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope.join(" ") + '&response_type=code&state=' + state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ try {
+ var requestToken = (event.url).split("code=")[1].split("&")[0];
+ $http({method: "post", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, url: "https://www.linkedin.com/uas/oauth2/accessToken", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }catch(e){
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ linkedin.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.magento.js b/www/lib/ng-cordova-oauth/src/oauth.magento.js
new file mode 100644
index 0000000..0bc355b
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.magento.js
@@ -0,0 +1,116 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.magento', ['oauth.utils'])
+ .factory('$ngCordovaMagento', magento);
+
+ function magento($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthMagento };
+
+ /*
+ * Sign into the Magento service
+ * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures
+ *
+ * @param string baseUrl
+ * @param string clientId
+ * @param string clientSecret
+ * @return promise
+ */
+ function oauthMagento(baseUrl, clientId, clientSecret) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ if(typeof jsSHA !== "undefined") {
+ var oauthObject = {
+ oauth_callback: "http://localhost/callback",
+ oauth_consumer_key: clientId,
+ oauth_nonce: $cordovaOauthUtility.createNonce(5),
+ oauth_signature_method: "HMAC-SHA1",
+ oauth_timestamp: Math.round((new Date()).getTime() / 1000.0),
+ oauth_version: "1.0"
+ };
+ var signatureObj = $cordovaOauthUtility.createSignature("POST", baseUrl + "/oauth/initiate", oauthObject, { oauth_callback: "http://localhost/callback" }, clientSecret);
+ $http.defaults.headers.post.Authorization = signatureObj.authorization_header;
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: baseUrl + "/oauth/initiate", data: "oauth_callback=http://localhost/callback" })
+ .success(function(requestTokenResult) {
+ var requestTokenParameters = (requestTokenResult).split("&");
+ var parameterMap = {};
+
+ for(var i = 0; i < requestTokenParameters.length; i++) {
+ parameterMap[requestTokenParameters[i].split("=")[0]] = requestTokenParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.hasOwnProperty("oauth_token") === false) {
+ deferred.reject("Oauth request token was not received");
+ }
+
+ var tokenSecret = parameterMap.oauth_token_secret;
+ var browserRef = window.cordova.InAppBrowser.open(baseUrl + '/oauth/authorize?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+
+ browserRef.addEventListener('loadstart', function(event) {
+ if ((event.url).indexOf("http://localhost/callback") === 0) {
+ var callbackResponse = (event.url).split("?")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.hasOwnProperty("oauth_verifier") === false) {
+ deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned");
+ }
+ delete oauthObject.oauth_signature;
+ delete oauthObject.oauth_callback;
+ oauthObject.oauth_token = parameterMap.oauth_token;
+ oauthObject.oauth_nonce = $cordovaOauthUtility.createNonce(5);
+ oauthObject.oauth_verifier = parameterMap.oauth_verifier;
+ var signatureObj = $cordovaOauthUtility.createSignature("POST", baseUrl + "/oauth/token", oauthObject, {}, clientSecret, tokenSecret);
+ $http.defaults.headers.post.Authorization = signatureObj.authorization_header;
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: baseUrl + "/oauth/token" })
+ .success(function(result) {
+ var accessTokenParameters = result.split("&");
+ var parameterMap = {};
+ for(var i = 0; i < accessTokenParameters.length; i++) {
+ parameterMap[accessTokenParameters[i].split("=")[0]] = accessTokenParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.hasOwnProperty("oauth_token_secret") === false) {
+ deferred.reject("Oauth access token was not received");
+ }
+
+ deferred.resolve(parameterMap);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+ } else {
+ deferred.reject("Missing jsSHA JavaScript library");
+ }
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ magento.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.meetup.js b/www/lib/ng-cordova-oauth/src/oauth.meetup.js
new file mode 100644
index 0000000..6a4b5c8
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.meetup.js
@@ -0,0 +1,59 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.meetup', ['oauth.utils'])
+ .factory('$ngCordovaMeetup', meetup);
+
+ function meetup($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthMeetup };
+
+ /*
+ * Sign into the Meetup service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthMeetup(clientId, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://secure.meetup.com/oauth2/authorize/?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve(parameterMap);
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ meetup.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.mercadolibre.js b/www/lib/ng-cordova-oauth/src/oauth.mercadolibre.js
new file mode 100644
index 0000000..3a2db3e
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.mercadolibre.js
@@ -0,0 +1,59 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.mercadolibre', ['oauth.utils'])
+ .factory('$ngCordovaMercadolibre', mercadolibre);
+
+ function mercadolibre($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthMercadolibre };
+
+ /*
+ * Sign into the Mercadolibre service
+ *
+ * @param string appId
+ * @param object options
+ * @return promise
+ */
+ function oauthMercadolibre(appId, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open("http://auth.mercadolibre.com.ar/authorization?client_id=" + appId + "&redirect_uri=" + redirect_uri + "&response_type=token", "_blank", "location=no,clearsessioncache=yes,clearcache=yes");
+ browserRef.addEventListener("loadstart", function(event) {
+ if ((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in, user_id: parameterMap.user_id, domains: parameterMap.domains });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ mercadolibre.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.netatmo.js b/www/lib/ng-cordova-oauth/src/oauth.netatmo.js
new file mode 100644
index 0000000..38b5e7b
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.netatmo.js
@@ -0,0 +1,103 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.netatmo', ['oauth.utils']).factory('$ngCordovaNetatmo', netatmo);
+
+ function netatmo($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthNetatmo };
+
+ /*
+ * Sign into the Netatmo service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthNetatmo(options) {
+
+ var deferred = $q.defer();
+ var fetchingToken = false;
+ var clientId = (options.clientId)? options.clientId: null;
+ var clientSecret = (options.clientSecret)? options.clientSecret: null;
+ var appScope = (options.appScope)? options.appScope: null;
+ var state = (options.state)? options.state: Math.random().toString(36).substr(2, 5);
+ var inappbrowserOptions = (options.inappbrowserOptions)? options.inappbrowserOptions: 'location=no,clearsessioncache=yes,clearcache=yes';
+
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+
+ var redirect_uri = "http://localhost/callback";
+ var authorize_uri = 'https://api.netatmo.com/oauth2/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope +'&state='+ state;
+ var browserRef = window.cordova.InAppBrowser.open(authorize_uri, '_blank', inappbrowserOptions);
+
+ browserRef.addEventListener('loadstart', inappbrowserLoadStarted);
+ browserRef.addEventListener('exit', inapbrowserExited);
+ } else {
+ deferred.reject({error: "no_inappbrowser_plugin"});
+ }
+ } else {
+ deferred.reject({error: "no_inappbrowser_plugin"});
+ }
+
+ function inappbrowserLoadStarted(event){
+
+ var hasNoRedirectUri = (event.url).indexOf(redirect_uri) === 0;
+ var redirectUriMatch = (event.url).split("?")[0] === redirect_uri;
+
+ if(hasNoRedirectUri && redirectUriMatch) {
+
+ fetchingToken = true;
+ browserRef.close();
+
+ //get response url parameters
+ var callbackResponse = (event.url).split("?")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var urlParameters = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ urlParameters[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ var requestToken = urlParameters.code;
+ var responseState = urlParameters.state;
+
+ if(state === responseState){
+
+ var httpOptions = {
+ method: "post",
+ url: "https://api.netatmo.com/oauth2/token",
+ data: 'grant_type=authorization_code&client_id='+ clientId +'&client_secret='+ clientSecret +'&code='+ requestToken +'&scope='+ appScope +'&redirect_uri='+ redirect_uri,
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
+ },
+ };
+
+ $http(httpOptions).success(requestTokenSuccess).error(requestTokenError).finally(requestTokenFinally);
+ } else {
+ deferred.reject({error: "string_missmatch"});
+ }
+ }
+ function requestTokenSuccess(success){
+ deferred.resolve(success);
+ }
+ function requestTokenError(error){
+ deferred.reject(error);
+ }
+ function requestTokenFinally(){}
+ }
+ function inapbrowserExited(event){
+
+ if(!fetchingToken){
+
+ var error = {error: "flow_canceled"};
+ deferred.reject(error);
+ }
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ netatmo.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.odnoklassniki.js b/www/lib/ng-cordova-oauth/src/oauth.odnoklassniki.js
new file mode 100644
index 0000000..966b300
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.odnoklassniki.js
@@ -0,0 +1,55 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.odnoklassniki', ['oauth.utils'])
+ .factory('$ngCordovaOdnoklassniki', odnoklassniki);
+
+ function odnoklassniki($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthOdnoklassniki };
+
+ /*
+ * Sign into the Odnoklassniki service
+ *
+ * @param string clientId
+ * @param array appScope (for example: "VALUABLE_ACCESS ,GROUP_CONTENT,VIDEO_CONTENT")
+ * @return promise
+ */
+ function oauthOdnoklassniki(clientId, appScope) {
+ var deferred = $q.defer();
+ if (window.cordova) {
+ if ($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var browserRef = window.cordova.InAppBrowser.open('http://www.odnoklassniki.ru/oauth/authorize?client_id=' + clientId + '&scope=' + appScope.join(",") + '&response_type=token&redirect_uri=http://localhost/callback' + '&layout=m', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function (event) {
+ if ((event.url).indexOf("http://localhost/callback") === 0) {
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for (var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, session_secret_key: parameterMap.session_secret_key });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ setTimeout(function () {
+ browserRef.close();
+ }, 10);
+ }
+ });
+ browserRef.addEventListener('exit', function (event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ odnoklassniki.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.pocket.js b/www/lib/ng-cordova-oauth/src/oauth.pocket.js
new file mode 100644
index 0000000..0bb0382
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.pocket.js
@@ -0,0 +1,86 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.pocket', ['oauth.utils'])
+ .factory('$ngCordovaPocket', pocket);
+
+ function pocket($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthPocket };
+
+ /*
+ * Sign into the Pocket service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthPocket(clientId, options) {
+ var deferred = $q.defer();
+ if (window.cordova) {
+ if ($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_url = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_url")) {
+ redirect_url = options.redirect_url;
+ }
+ }
+
+ var data = "consumer_key=" + clientId + "&redirect_uri=" + encodeURIComponent(redirect_url);
+ $http({
+ method: "post",
+ url: "https://getpocket.com/v3/oauth/request",
+ headers: {
+ "X-Accept": "application/x-www-form-urlencoded",
+ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
+ },
+ data: data
+ })
+ .success(function(data) {
+ var code = data.split("code=")[1];
+ var browserRef = window.cordova.InAppBrowser.open('https://getpocket.com/auth/authorize?request_token=' + code + '&redirect_uri=' + redirect_url, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_url) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ data = "consumer_key=" + clientId + "&code=" + code;
+ $http({
+ method: "post",
+ url: "https://getpocket.com/v3/oauth/authorize",
+ headers: {
+ "X-Accept": "application/x-www-form-urlencoded",
+ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
+ },
+ data: data
+ })
+ .success(function(result) {
+ deferred.resolve(result);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ pocket.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.rally.js b/www/lib/ng-cordova-oauth/src/oauth.rally.js
new file mode 100644
index 0000000..e55163e
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.rally.js
@@ -0,0 +1,63 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.rally', ['oauth.utils'])
+ .factory('$ngCordovaRally', rally);
+
+ function rally($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthRally };
+
+ /*
+ * Sign into the Rally service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthRally(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://rally1.rallydev.com/login/oauth2/auth?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf("http://localhost/callback") === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://rally1.rallydev.com/login/oauth2/auth", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ rally.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.reddit.js b/www/lib/ng-cordova-oauth/src/oauth.reddit.js
new file mode 100644
index 0000000..f15ace4
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.reddit.js
@@ -0,0 +1,63 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.reddit', ['oauth.utils'])
+ .factory('$ngCordovaReddit', reddit);
+
+ function reddit($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthReddit };
+
+ /*
+ * Sign into the Reddit service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthReddit(clientId, clientSecret, appScope, compact, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://ssl.reddit.com/api/v1/authorize' + (compact ? '.compact' : '') + '?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&duration=permanent&state=ngcordovaoauth&scope=' + appScope.join(",") + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http.defaults.headers.post.Authorization = 'Basic ' + btoa(clientId + ":" + clientSecret);
+ $http({method: "post", url: "https://ssl.reddit.com/api/v1/access_token", data: "redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ reddit.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.salesforce.js b/www/lib/ng-cordova-oauth/src/oauth.salesforce.js
new file mode 100644
index 0000000..0938a33
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.salesforce.js
@@ -0,0 +1,74 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.salesforce', ['oauth.utils'])
+ .factory('$ngCordovaSalesforce', salesforce);
+
+ function salesforce($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthSalesforce };
+
+ /*
+ * Sign into the Salesforce service
+ *
+ * Suggestion: use salesforce oauth with forcetk.js(as SDK)
+ *
+ * @param string loginUrl (such as: https://login.salesforce.com ; please notice community login)
+ * @param string clientId (copy from connection app info)
+ * @param string redirectUri (callback url in connection app info)
+ * @return promise
+ */
+ function oauthSalesforce(loginUrl, clientId) {
+ var redirectUri = 'http://localhost/callback';
+ var getAuthorizeUrl = function (loginUrl, clientId, redirectUri) {
+ return loginUrl+'services/oauth2/authorize?display=touch'+
+ '&response_type=token&client_id='+escape(clientId)+
+ '&redirect_uri='+escape(redirectUri);
+ };
+ var startWith = function(string, str) {
+ return (string.substr(0, str.length) === str);
+ };
+
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var browserRef = window.cordova.InAppBrowser.open(getAuthorizeUrl(loginUrl, clientId, redirectUri), "_blank", "location=no,clearsessioncache=yes,clearcache=yes");
+ browserRef.addEventListener("loadstart", function(event) {
+ if(startWith(event.url, redirectUri)) {
+ var oauthResponse = {};
+
+ var fragment = (event.url).split('#')[1];
+
+ if (fragment) {
+ var nvps = fragment.split('&');
+ for (var nvp in nvps) {
+ var parts = nvps[nvp].split('=');
+ oauthResponse[parts[0]] = unescape(parts[1]);
+ }
+ }
+
+ if (typeof oauthResponse === 'undefined' ||
+ typeof oauthResponse.access_token === 'undefined') {
+ deferred.reject("Problem authenticating");
+ } else {
+ deferred.resolve(oauthResponse);
+ }
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ salesforce.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.slack.js b/www/lib/ng-cordova-oauth/src/oauth.slack.js
new file mode 100644
index 0000000..7ddd50b
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.slack.js
@@ -0,0 +1,64 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.slack', ['oauth.utils'])
+ .factory('$ngCordovaSlack', slack);
+
+ function slack($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthSlack };
+
+ /*
+ * Sign into the Slack service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthSlack(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+
+ var browserRef = window.cordova.InAppBrowser.open('https://slack.com/oauth/authorize' + '?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&state=ngcordovaoauth&scope=' + appScope.join(","), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://slack.com/api/oauth.access", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ slack.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.spotify.js b/www/lib/ng-cordova-oauth/src/oauth.spotify.js
new file mode 100644
index 0000000..941a6e6
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.spotify.js
@@ -0,0 +1,75 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.spotify', ['oauth.utils'])
+ .factory('$ngCordovaSpotify', spotify);
+
+ function spotify($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthSpotify };
+
+ /*
+ * Sign into the Spotify service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthSpotify(clientId, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ var response_type = "token";
+ var state = "";
+ var show_dialog = "";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ if(options.hasOwnProperty("response_type")) {
+ response_type = options.response_type;
+ }
+ if(options.hasOwnProperty("state")) {
+ state = "&state=" + options.state;
+ }
+ if(options.hasOwnProperty("show_dialog")) {
+ show_dialog = "&show_dialog=" + options.show_dialog;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://accounts.spotify.com/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=' + response_type + state + '&scope=' + appScope.join(" ") + show_dialog, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var splitChar = (response_type === "code") ? "?" : "#";
+ var callbackResponse = (event.url).split(splitChar)[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(response_type === "token" && parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in, account_username: parameterMap.account_username });
+ } else if(response_type === "code" && parameterMap.code !== undefined && parameterMap.code !== null) {
+ deferred.resolve({ code: parameterMap.code, state: parameterMap.state });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ spotify.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.strava.js b/www/lib/ng-cordova-oauth/src/oauth.strava.js
new file mode 100644
index 0000000..216ff8c
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.strava.js
@@ -0,0 +1,63 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.strava', ['oauth.utils'])
+ .factory('$ngCordovaStrava', strava);
+
+ function strava($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthStrava };
+
+ /*
+ * Sign into the Strava service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthStrava(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://www.strava.com/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope.join(",") + '&response_type=code&approval_prompt=force', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://www.strava.com/oauth/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ strava.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.stripe.js b/www/lib/ng-cordova-oauth/src/oauth.stripe.js
new file mode 100644
index 0000000..db71894
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.stripe.js
@@ -0,0 +1,63 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.stripe', ['oauth.utils'])
+ .factory('$ngCordovaStripe', stripe);
+
+ function stripe($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthStripe };
+
+ /*
+ * Sign into the Stripe service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthStripe(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://connect.stripe.com/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf("http://localhost/callback") === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://connect.stripe.com/oauth/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=" + redirect_uri + "&grant_type=authorization_code" + "&code=" + requestToken })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ stripe.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.trakttv.js b/www/lib/ng-cordova-oauth/src/oauth.trakttv.js
new file mode 100644
index 0000000..54043f6
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.trakttv.js
@@ -0,0 +1,67 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.trakttv', ['oauth.utils'])
+ .factory('$ngCordovaTraktTv', trakttv);
+
+ function trakttv($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthTraktTv };
+
+ /*
+ * Sign into the Trakt.tv service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param string state
+ * @param object options
+ * @return promise
+ */
+ function oauthTraktTv(clientId, clientSecret, appScope, state, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://trakt.tv/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=code&state=' + state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ try {
+ var requestToken = (event.url).split("code=")[1].split("&")[0];
+ $http({method: "post", headers: {'Content-Type': 'application/json'}, url: "https://trakt.tv/oauth/token", data: {'code': requestToken, 'client_id': clientId, 'client_secret': clientSecret, 'redirect_uri': redirect_uri, 'grant_type': 'authorization_code'} })
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }catch(e){
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ trakttv.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.twitter.js b/www/lib/ng-cordova-oauth/src/oauth.twitter.js
new file mode 100644
index 0000000..6bf2777
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.twitter.js
@@ -0,0 +1,124 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.twitter', ['oauth.utils'])
+ .factory('$ngCordovaTwitter', twitter);
+
+ function twitter($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthTwitter };
+
+ /*
+ * Sign into the Twitter service
+ * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @return promise
+ */
+ function oauthTwitter(clientId, clientSecret, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+
+ if(typeof jsSHA !== "undefined") {
+ var oauthObject = {
+ oauth_consumer_key: clientId,
+ oauth_nonce: $cordovaOauthUtility.createNonce(10),
+ oauth_signature_method: "HMAC-SHA1",
+ oauth_timestamp: Math.round((new Date()).getTime() / 1000.0),
+ oauth_version: "1.0"
+ };
+ var signatureObj = $cordovaOauthUtility.createSignature("POST", "https://api.twitter.com/oauth/request_token", oauthObject, { oauth_callback: redirect_uri }, clientSecret);
+ $http({
+ method: "post",
+ url: "https://api.twitter.com/oauth/request_token",
+ headers: {
+ "Authorization": signatureObj.authorization_header,
+ "Content-Type": "application/x-www-form-urlencoded"
+ },
+ data: "oauth_callback=" + encodeURIComponent(redirect_uri)
+ })
+ .success(function(requestTokenResult) {
+ var requestTokenParameters = (requestTokenResult).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < requestTokenParameters.length; i++) {
+ parameterMap[requestTokenParameters[i].split("=")[0]] = requestTokenParameters[i].split("=")[1];
+ }
+ if(parameterMap.hasOwnProperty("oauth_token") === false) {
+ deferred.reject("Oauth request token was not received");
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://api.twitter.com/oauth/authenticate?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var callbackResponse = (event.url).split("?")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.hasOwnProperty("oauth_verifier") === false) {
+ deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned");
+ }
+ delete oauthObject.oauth_signature;
+ oauthObject.oauth_token = parameterMap.oauth_token;
+ var signatureObj = $cordovaOauthUtility.createSignature("POST", "https://api.twitter.com/oauth/access_token", oauthObject, { oauth_verifier: parameterMap.oauth_verifier }, clientSecret);
+ $http({
+ method: "post",
+ url: "https://api.twitter.com/oauth/access_token",
+ headers: {
+ "Authorization": signatureObj.authorization_header
+ },
+ params: {
+ "oauth_verifier": parameterMap.oauth_verifier
+ }
+ })
+ .success(function(result) {
+ var accessTokenParameters = result.split("&");
+ var parameterMap = {};
+ for(var i = 0; i < accessTokenParameters.length; i++) {
+ parameterMap[accessTokenParameters[i].split("=")[0]] = accessTokenParameters[i].split("=")[1];
+ }
+ if(parameterMap.hasOwnProperty("oauth_token_secret") === false) {
+ deferred.reject("Oauth access token was not received");
+ }
+ deferred.resolve(parameterMap);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+ } else {
+ deferred.reject("Missing jsSHA JavaScript library");
+ }
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ twitter.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.uber.js b/www/lib/ng-cordova-oauth/src/oauth.uber.js
new file mode 100644
index 0000000..c947564
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.uber.js
@@ -0,0 +1,65 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.uber', ['oauth.utils'])
+ .factory('$ngCordovaUber', uber);
+
+ function uber($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthUber };
+
+ /*
+ * Sign into the Uber service
+ *
+ * @param string clientId
+ * @param appScope array
+ * @param object options
+ * @return promise
+ */
+ function oauthUber(clientId, appScope, options) {
+
+ var deferred = $q.defer();
+ if(window.cordova) {
+
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://login.uber.com/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token&scope=' + appScope.join(" "), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, token_type: parameterMap.token_type, expires_in: parameterMap.expires_in, scope: parameterMap.scope });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+
+ }
+ }
+
+ uber.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.untappd.js b/www/lib/ng-cordova-oauth/src/oauth.untappd.js
new file mode 100644
index 0000000..e5b097e
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.untappd.js
@@ -0,0 +1,65 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.untappd', ['oauth.utils'])
+ .factory('$ngCordovaUntappd', untappd);
+
+ function untappd($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthUntappd };
+
+ /*
+ * Sign into the Untappd service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthUntappd(clientId, options) {
+ var deferred = $q.defer();
+ if (window.cordova) {
+ if ($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_url = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_url")) {
+ redirect_url = options.redirect_url;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://untappd.com/oauth/authenticate/?client_id=' + clientId + '&redirect_url=' + redirect_url + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function (event) {
+ if ((event.url).indexOf(redirect_url) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for (var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ var promiseResponse = {
+ access_token: parameterMap.access_token
+ };
+ deferred.resolve(promiseResponse);
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ untappd.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.venmo.js b/www/lib/ng-cordova-oauth/src/oauth.venmo.js
new file mode 100644
index 0000000..4de70d5
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.venmo.js
@@ -0,0 +1,65 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.venmo', ['oauth.utils'])
+ .factory('$ngCordovaVenmo', venmo);
+
+ function venmo($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthVenmo };
+
+ /*
+ * Sign into the Venmo service
+ *
+ * @param string clientId
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthVenmo(clientId, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://api.venmo.com/v1/oauth/authorize?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token&scope=' + appScope.join(" "), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("?")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token });
+ } else if(parameterMap.error !== undefined && parameterMap.error !== null) {
+ deferred.reject((parameterMap.error).replace("+", " "));
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ venmo.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.vkontakte.js b/www/lib/ng-cordova-oauth/src/oauth.vkontakte.js
new file mode 100644
index 0000000..2fcd906
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.vkontakte.js
@@ -0,0 +1,59 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.vkontakte', ['oauth.utils'])
+ .factory('$ngCordovaVkontakte', vkontakte);
+
+ function vkontakte($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthvKontakte };
+
+ /*
+ * Sign into the Vkontakte service
+ *
+ * @param string clientId
+ * @param array appScope (for example: "friends,wall,photos,messages")
+ * @return promise
+ */
+ function oauthvKontakte(clientId, appScope) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var browserRef = window.cordova.InAppBrowser.open('https://oauth.vk.com/authorize?client_id=' + clientId + '&redirect_uri=http://oauth.vk.com/blank.html&response_type=token&scope=' + appScope.join(",") + '&display=touch&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ var tmp = (event.url).split("#");
+ if (tmp[0] == 'https://oauth.vk.com/blank.html' || tmp[0] == 'http://oauth.vk.com/blank.html') {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ var output = { access_token: parameterMap.access_token, expires_in: parameterMap.expires_in };
+ if(parameterMap.email !== undefined && parameterMap.email !== null){
+ output.email = parameterMap.email;
+ }
+ deferred.resolve(output);
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ vkontakte.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.weibo.js b/www/lib/ng-cordova-oauth/src/oauth.weibo.js
new file mode 100644
index 0000000..6a4fd30
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.weibo.js
@@ -0,0 +1,73 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.weibo', ['oauth.utils'])
+ .factory('$ngCordovaWeibo', weibo);
+
+ function weibo($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthWeibo };
+
+ /*
+ * Sign into the Weibo service
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthWeibo(clientId, clientSecret, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var flowUrl = "https://open.weibo.cn/oauth2/authorize?display=mobile&client_id=" + clientId + "&redirect_uri=" + redirect_uri + "&scope=" + appScope.join(",");
+ if(options !== undefined) {
+ if(options.hasOwnProperty("language")) {
+ flowUrl += "&language=" + options.language;
+ }
+ if(options.hasOwnProperty("forcelogin")) {
+ flowUrl += "&forcelogin=" + options.forcelogin;
+ }
+ }
+
+ var browserRef = window.cordova.InAppBrowser.open(flowUrl, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var requestToken = (event.url).split("code=")[1];
+ $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+ $http({method: "post", url: "https://api.weibo.com/oauth2/access_token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&grant_type=authorization_code&code=" + requestToken + "&redirect_uri=" + redirect_uri})
+ .success(function(data) {
+ deferred.resolve(data);
+ })
+ .error(function(data, status) {
+ deferred.reject("Problem authenticating");
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ weibo.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.windowslive.js b/www/lib/ng-cordova-oauth/src/oauth.windowslive.js
new file mode 100644
index 0000000..84523c4
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.windowslive.js
@@ -0,0 +1,63 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.windowslive', ['oauth.utils'])
+ .factory('$ngCordovaWindowslive', windowslive);
+
+ function windowslive($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthWindowslive };
+
+ /*
+ * Sign into the Windows Live Connect service
+ *
+ * @param string clientId
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthWindowslive(clientId, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "https://login.live.com/oauth20_desktop.srf";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://login.live.com/oauth20_authorize.srf?client_id=' + clientId + "&scope=" + appScope.join(",") + '&response_type=token&display=touch' + '&redirect_uri=' + redirect_uri, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function (event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit", function (event) { });
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for (var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function (event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ windowslive.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.withings.js b/www/lib/ng-cordova-oauth/src/oauth.withings.js
new file mode 100644
index 0000000..56a7c48
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.withings.js
@@ -0,0 +1,113 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.withings', ['oauth.utils'])
+ .factory('$ngCordovaWithings', withings);
+
+ function withings($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthWithings };
+
+ /*
+ * Sign into the Withings service
+ * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @return promise
+ */
+ function oauthWithings(clientId, clientSecret) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ if(typeof jsSHA !== "undefined") {
+
+ // Step 1 : get a oAuth "request token"
+ var oauthObject = $cordovaOauthUtility.generateOauthParametersInstance(clientId);
+ oauthObject.oauth_callback = 'http://localhost/callback';
+
+ var requestTokenUrlBase = "https://oauth.withings.com/account/request_token";
+ var signatureObj = $cordovaOauthUtility.createSignature("GET", requestTokenUrlBase, {}, oauthObject, clientSecret);
+ oauthObject.oauth_signature = signatureObj.signature;
+
+ var requestTokenParameters = $cordovaOauthUtility.generateUrlParameters(oauthObject);
+
+ $http({method: "get", url: requestTokenUrlBase + "?" + requestTokenParameters })
+ .success(function(requestTokenResult) {
+
+ // Step 2 : End-user authorization
+ var parameterMap = $cordovaOauthUtility.parseResponseParameters(requestTokenResult);
+ if(!parameterMap.oauth_token) {
+ deferred.reject("Oauth request token was not received");
+ }
+ var oauthObject = $cordovaOauthUtility.generateOauthParametersInstance(clientId);
+ oauthObject.oauth_token = parameterMap.oauth_token;
+
+ // used in step 3
+ var oauthTokenSecret = parameterMap.oauth_token_secret;
+
+ var authorizeUrlBase = "https://oauth.withings.com/account/authorize";
+ var signatureObj = $cordovaOauthUtility.createSignature("GET", authorizeUrlBase, {}, oauthObject, clientSecret);
+ oauthObject.oauth_signature = signatureObj.signature;
+
+ var authorizeParameters = $cordovaOauthUtility.generateUrlParameters(oauthObject);
+ var browserRef = window.cordova.InAppBrowser.open(authorizeUrlBase + '?' + authorizeParameters, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+
+ // STEP 3: User Data Access token
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf("http://localhost/callback") === 0) {
+ var callbackResponse = (event.url).split("?")[1];
+ parameterMap = $cordovaOauthUtility.parseResponseParameters(callbackResponse);
+ if(!parameterMap.oauth_verifier) {
+ deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned");
+ }
+
+ var oauthObject = $cordovaOauthUtility.generateOauthParametersInstance(clientId);
+ oauthObject.oauth_token = parameterMap.oauth_token;
+
+ var accessTokenUrlBase = "https://oauth.withings.com/account/access_token";
+ var signatureObj = $cordovaOauthUtility.createSignature("GET", accessTokenUrlBase, {}, oauthObject, clientSecret, oauthTokenSecret);
+ oauthObject.oauth_signature = signatureObj.signature;
+
+ var accessTokenParameters = $cordovaOauthUtility.generateUrlParameters(oauthObject);
+
+ $http({method: "get", url: accessTokenUrlBase + '?' + accessTokenParameters})
+ .success(function(result) {
+ var parameterMap = $cordovaOauthUtility.parseResponseParameters(result);
+ if(!parameterMap.oauth_token_secret) {
+ deferred.reject("Oauth access token was not received");
+ }
+ deferred.resolve(parameterMap);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+ } else {
+ deferred.reject("Missing jsSHA JavaScript library");
+ }
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ withings.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.xing.js b/www/lib/ng-cordova-oauth/src/oauth.xing.js
new file mode 100644
index 0000000..8b3ec50
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.xing.js
@@ -0,0 +1,126 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.xing', ['oauth.utils'])
+ .factory('$ngCordovaXing', xing);
+
+ function xing($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthXing };
+
+ /*
+ * Sign into the Xing service
+ * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures
+ *
+ * @param string clientId
+ * @param string clientSecret
+ * @param object options
+ * @return promise
+ */
+ function oauthXing(clientId, clientSecret, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = 'http://localhost/callback';
+ if(options !== undefined) {
+ if(options.hasOwnProperty('redirect_uri')) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+
+ if(typeof jsSHA !== 'undefined') {
+ var oauthObject = {
+ oauth_consumer_key: clientId,
+ oauth_nonce: $cordovaOauthUtility.createNonce(10),
+ oauth_signature_method: 'HMAC-SHA1',
+ oauth_timestamp: Math.round((new Date()).getTime() / 1000.0),
+ oauth_version: '1.0'
+ };
+ var signatureObj = $cordovaOauthUtility.createSignature('POST', 'https://api.xing.com/v1/request_token', oauthObject, { oauth_callback: redirect_uri }, clientSecret);
+ $http({
+ method: 'post',
+ url: 'https://api.xing.com/v1/request_token',
+ headers: {
+ 'Authorization': signatureObj.authorization_header,
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ },
+ data: 'oauth_callback=' + encodeURIComponent(redirect_uri)
+ })
+ .success(function(requestTokenResult) {
+ var requestTokenParameters = (requestTokenResult).split('&');
+ var parameterMap = {};
+ for(var i = 0; i < requestTokenParameters.length; i++) {
+ parameterMap[requestTokenParameters[i].split('=')[0]] = requestTokenParameters[i].split('=')[1];
+ }
+ if(parameterMap.hasOwnProperty('oauth_token') === false) {
+ deferred.reject('Oauth request token was not received');
+ }
+ var oauthTokenSecret = parameterMap.oauth_token_secret;
+ var browserRef = window.cordova.InAppBrowser.open('https://api.xing.com/v1/authorize?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ var callbackResponse = (event.url).split('?')[1];
+ var responseParameters = (callbackResponse).split('&');
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split('=')[0]] = responseParameters[i].split('=')[1];
+ }
+ if(parameterMap.hasOwnProperty('oauth_verifier') === false) {
+ deferred.reject('Browser authentication failed to complete. No oauth_verifier was returned');
+ }
+ delete oauthObject.oauth_signature;
+ oauthObject.oauth_token = parameterMap.oauth_token;
+ var signatureObj = $cordovaOauthUtility.createSignature('POST', 'https://api.xing.com/v1/access_token', oauthObject, { oauth_verifier: parameterMap.oauth_verifier }, clientSecret, oauthTokenSecret);
+ $http({
+ method: 'post',
+ url: 'https://api.xing.com/v1/access_token',
+ headers: {
+ 'Authorization': signatureObj.authorization_header
+ },
+ params: {
+ 'oauth_verifier': parameterMap.oauth_verifier
+ }
+ })
+ .success(function(result) {
+ var accessTokenParameters = result.split('&');
+ var parameterMap = {};
+ for(var i = 0; i < accessTokenParameters.length; i++) {
+ parameterMap[accessTokenParameters[i].split('=')[0]] = accessTokenParameters[i].split('=')[1];
+ }
+ if(parameterMap.hasOwnProperty('oauth_token_secret') === false) {
+ deferred.reject('Oauth access token was not received');
+ }
+ deferred.resolve(parameterMap);
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ })
+ .finally(function() {
+ setTimeout(function() {
+ browserRef.close();
+ }, 10);
+ });
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject('The sign in flow was canceled');
+ });
+ })
+ .error(function(error) {
+ deferred.reject(error);
+ });
+ } else {
+ deferred.reject('Missing jsSHA JavaScript library');
+ }
+ } else {
+ deferred.reject('Could not find InAppBrowser plugin');
+ }
+ } else {
+ deferred.reject('Cannot authenticate via a web browser');
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ xing.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.yahoo.js b/www/lib/ng-cordova-oauth/src/oauth.yahoo.js
new file mode 100644
index 0000000..e1335da
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.yahoo.js
@@ -0,0 +1,79 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.yahoo', ['oauth.utils'])
+ .factory('$ngCordovaYahoo', yahoo);
+
+ function yahoo($q, $cordovaOauthUtility) {
+ return { signin: oauthYahoo };
+
+ /*
+ * Sign into the Yahoo service
+ *
+ * @param string clientId
+ * @param array appScope
+ * @param object options
+ * @return promise
+ */
+ function oauthYahoo(clientId, appScope, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+
+ var providerUrl = 'https://api.login.yahoo.com/oauth2/request_auth?client_id=' + clientId;
+ providerUrl += '&redirect_uri=' + redirect_uri;
+ providerUrl += '&response_type=token';
+ providerUrl += '&scope=' + appScope.join(" ");
+
+ var browserRef = window.cordova.InAppBrowser.open(
+ providerUrl,
+ '_blank',
+ 'location=no,clearsessioncache=yes,clearcache=yes'
+ );
+
+ browserRef.addEventListener("loadstart", function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = {};
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({
+ access_token: parameterMap.access_token,
+ token_type: parameterMap.token_type,
+ expires_in: parameterMap.expires_in,
+ id_token: parameterMap.id_token
+ });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+ return deferred.promise;
+ }
+ }
+
+ yahoo.$inject = ['$q', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/oauth.yammer.js b/www/lib/ng-cordova-oauth/src/oauth.yammer.js
new file mode 100644
index 0000000..dbae9aa
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/oauth.yammer.js
@@ -0,0 +1,62 @@
+(function() {
+ 'use strict';
+
+ angular.module('oauth.yammer', ['oauth.utils'])
+ .factory('$ngCordovaYammer', yammer);
+
+ function yammer($q, $http, $cordovaOauthUtility) {
+ return { signin: oauthYammer };
+
+ /*
+ * Sign into the Yammer service
+ *
+ * @param string clientId
+ * @param object options
+ * @return promise
+ */
+ function oauthYammer(clientId, options) {
+ var deferred = $q.defer();
+ if(window.cordova) {
+ if($cordovaOauthUtility.isInAppBrowserInstalled()) {
+ var redirect_uri = "http://localhost/callback";
+ if(options !== undefined) {
+ if(options.hasOwnProperty("redirect_uri")) {
+ redirect_uri = options.redirect_uri;
+ }
+ }
+ var browserRef = window.cordova.InAppBrowser.open('https://www.yammer.com/dialog/oauth?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
+ browserRef.addEventListener('loadstart', function(event) {
+ if((event.url).indexOf(redirect_uri) === 0) {
+ browserRef.removeEventListener("exit",function(event){});
+ browserRef.close();
+ var callbackResponse = (event.url).split("#")[1];
+ var responseParameters = (callbackResponse).split("&");
+ var parameterMap = [];
+
+ for(var i = 0; i < responseParameters.length; i++) {
+ parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
+ }
+
+ if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
+ deferred.resolve({ access_token: parameterMap.access_token });
+ } else {
+ deferred.reject("Problem authenticating");
+ }
+ }
+ });
+ browserRef.addEventListener('exit', function(event) {
+ deferred.reject("The sign in flow was canceled");
+ });
+ } else {
+ deferred.reject("Could not find InAppBrowser plugin");
+ }
+ } else {
+ deferred.reject("Cannot authenticate via a web browser");
+ }
+
+ return deferred.promise;
+ }
+ }
+
+ yammer.$inject = ['$q', '$http', '$cordovaOauthUtility'];
+})();
diff --git a/www/lib/ng-cordova-oauth/src/plugin.js b/www/lib/ng-cordova-oauth/src/plugin.js
new file mode 100644
index 0000000..8bbe637
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/plugin.js
@@ -0,0 +1,63 @@
+/*
+ * Cordova AngularJS Oauth
+ *
+ * Created by Nic Raboy
+ * http://www.nraboy.com
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Use Oauth sign in for various web services.
+ *
+ *
+ * REQUIRES:
+ *
+ * Apache Cordova 3.5+
+ * Apache InAppBrowser Plugin
+ * Apache Cordova Whitelist Plugin
+ *
+ *
+ * SUPPORTS:
+ *
+ * 500px
+ * Dropbox
+ * Digital Ocean
+ * Google
+ * GitHub
+ * Facebook
+ * LinkedIn
+ * Instagram
+ * Box
+ * Reddit
+ * Twitter
+ * Meetup
+ * Salesforce
+ * Strava
+ * Withings
+ * Foursquare
+ * Magento
+ * vkontakte
+ * Odnoklassniki
+ * ADFS
+ * Imgur
+ * Spotify
+ * Uber
+ * Windows Live Connect
+ * Yammer
+ * Venmo
+ * Stripe
+ * Rally
+ * Family Search
+ * Envato
+ * Slack
+ * Jawbone
+ * Untappd
+ * Xing
+ * Trakt.tv
+ */
+
+angular.module("ngCordovaOauth", [
+ "oauth.providers",
+ "oauth.utils"
+]);
diff --git a/www/lib/ng-cordova-oauth/src/utility.js b/www/lib/ng-cordova-oauth/src/utility.js
new file mode 100644
index 0000000..7cff09f
--- /dev/null
+++ b/www/lib/ng-cordova-oauth/src/utility.js
@@ -0,0 +1,159 @@
+(function() {
+ angular.module("oauth.utils", [])
+ .factory("$cordovaOauthUtility", cordovaOauthUtility);
+
+ function cordovaOauthUtility($q) {
+ return {
+ isInAppBrowserInstalled: isInAppBrowserInstalled,
+ createSignature: createSignature,
+ createNonce: createNonce,
+ generateUrlParameters: generateUrlParameters,
+ parseResponseParameters: parseResponseParameters,
+ generateOauthParametersInstance: generateOauthParametersInstance
+ };
+
+ /*
+ * Check to see if the mandatory InAppBrowser plugin is installed
+ *
+ * @param
+ * @return boolean
+ */
+ function isInAppBrowserInstalled() {
+ var cordovaPluginList = cordova.require("cordova/plugin_list");
+ var inAppBrowserNames = ["cordova-plugin-inappbrowser", "cordova-plugin-inappbrowser.inappbrowser", "org.apache.cordova.inappbrowser"];
+
+ if (Object.keys(cordovaPluginList.metadata).length === 0) {
+ var formatedPluginList = cordovaPluginList.map(
+ function(plugin) {
+ return plugin.id || plugin.pluginId;
+ });
+
+ return inAppBrowserNames.some(function(name) {
+ return formatedPluginList.indexOf(name) != -1 ? true : false;
+ });
+ } else {
+ return inAppBrowserNames.some(function(name) {
+ return cordovaPluginList.metadata.hasOwnProperty(name);
+ });
+ }
+ }
+
+ /*
+ * Sign an Oauth 1.0 request
+ *
+ * @param string method
+ * @param string endPoint
+ * @param object headerParameters
+ * @param object bodyParameters
+ * @param string secretKey
+ * @param string tokenSecret (optional)
+ * @return object
+ */
+ function createSignature(method, endPoint, headerParameters, bodyParameters, secretKey, tokenSecret) {
+ if(typeof jsSHA !== "undefined") {
+ var headerAndBodyParameters = angular.copy(headerParameters);
+ var bodyParameterKeys = Object.keys(bodyParameters);
+
+ for(var i = 0; i < bodyParameterKeys.length; i++) {
+ headerAndBodyParameters[bodyParameterKeys[i]] = encodeURIComponent(bodyParameters[bodyParameterKeys[i]]);
+ }
+
+ var signatureBaseString = method + "&" + encodeURIComponent(endPoint) + "&";
+ var headerAndBodyParameterKeys = (Object.keys(headerAndBodyParameters)).sort();
+
+ for(i = 0; i < headerAndBodyParameterKeys.length; i++) {
+ if(i == headerAndBodyParameterKeys.length - 1) {
+ signatureBaseString += encodeURIComponent(headerAndBodyParameterKeys[i] + "=" + headerAndBodyParameters[headerAndBodyParameterKeys[i]]);
+ } else {
+ signatureBaseString += encodeURIComponent(headerAndBodyParameterKeys[i] + "=" + headerAndBodyParameters[headerAndBodyParameterKeys[i]] + "&");
+ }
+ }
+
+ var oauthSignatureObject = new jsSHA(signatureBaseString, "TEXT");
+
+ var encodedTokenSecret = '';
+ if (tokenSecret) {
+ encodedTokenSecret = encodeURIComponent(tokenSecret);
+ }
+
+ headerParameters.oauth_signature = encodeURIComponent(oauthSignatureObject.getHMAC(encodeURIComponent(secretKey) + "&" + encodedTokenSecret, "TEXT", "SHA-1", "B64"));
+ var headerParameterKeys = Object.keys(headerParameters);
+ var authorizationHeader = 'OAuth ';
+
+ for(i = 0; i < headerParameterKeys.length; i++) {
+ if(i == headerParameterKeys.length - 1) {
+ authorizationHeader += headerParameterKeys[i] + '="' + headerParameters[headerParameterKeys[i]] + '"';
+ } else {
+ authorizationHeader += headerParameterKeys[i] + '="' + headerParameters[headerParameterKeys[i]] + '",';
+ }
+ }
+
+ return { signature_base_string: signatureBaseString, authorization_header: authorizationHeader, signature: headerParameters.oauth_signature };
+ } else {
+ return "Missing jsSHA JavaScript library";
+ }
+ }
+
+ /*
+ * Create Random String Nonce
+ *
+ * @param integer length
+ * @return string
+ */
+ function createNonce(length) {
+ var text = "";
+ var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+
+ for(var i = 0; i < length; i++) {
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
+ }
+
+ return text;
+ }
+
+ function generateUrlParameters(parameters) {
+ var sortedKeys = Object.keys(parameters);
+ sortedKeys.sort();
+
+ var params = "";
+ var amp = "";
+
+ for (var i = 0 ; i < sortedKeys.length; i++) {
+ params += amp + sortedKeys[i] + "=" + parameters[sortedKeys[i]];
+ amp = "&";
+ }
+
+ return params;
+ }
+
+ function parseResponseParameters(response) {
+ if (response.split) {
+ var parameters = response.split("&");
+ var parameterMap = {};
+
+ for(var i = 0; i < parameters.length; i++) {
+ parameterMap[parameters[i].split("=")[0]] = parameters[i].split("=")[1];
+ }
+
+ return parameterMap;
+ }
+ else {
+ return {};
+ }
+ }
+
+ function generateOauthParametersInstance(consumerKey) {
+ var nonceObj = new jsSHA(Math.round((new Date()).getTime() / 1000.0), "TEXT");
+ var oauthObject = {
+ oauth_consumer_key: consumerKey,
+ oauth_nonce: nonceObj.getHash("SHA-1", "HEX"),
+ oauth_signature_method: "HMAC-SHA1",
+ oauth_timestamp: Math.round((new Date()).getTime() / 1000.0),
+ oauth_version: "1.0"
+ };
+ return oauthObject;
+ }
+ }
+
+ cordovaOauthUtility.$inject = ['$q'];
+})();
diff --git a/www/lib/ng-facebook/.bower.json b/www/lib/ng-facebook/.bower.json
deleted file mode 100644
index 65d2a31..0000000
--- a/www/lib/ng-facebook/.bower.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "name": "ng-facebook",
- "main": "ngFacebook.js",
- "version": "0.1.6",
- "homepage": "https://github.com/GoDisco/ngFacebook",
- "authors": [
- "AlmogBaku "
- ],
- "description": "Angular service to handle facebook api",
- "keywords": [
- "facebook",
- "facebook-api",
- "service",
- "angularjs",
- "angular",
- "ngFacebook",
- "api",
- "facebook-sdk",
- "sdk"
- ],
- "license": "MIT",
- "dependencies": {
- "angular": ">=1.0.0 <2.0.0"
- },
- "_release": "0.1.6",
- "_resolution": {
- "type": "version",
- "tag": "0.1.6",
- "commit": "536f836c28bdc8d3d4f1ced2376f9b8d0256ef8e"
- },
- "_source": "https://github.com/GoDisco/ngFacebook.git",
- "_target": "^0.1.6",
- "_originalSource": "ng-facebook",
- "_direct": true
-}
\ No newline at end of file
diff --git a/www/lib/ng-facebook/.gitignore b/www/lib/ng-facebook/.gitignore
deleted file mode 100644
index 30bf554..0000000
--- a/www/lib/ng-facebook/.gitignore
+++ /dev/null
@@ -1,59 +0,0 @@
-# Created by .ignore support plugin (hsz.mobi)
-### JetBrains template
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
-
-*.iml
-
-## Directory-based project format:
-.idea/
-# if you remove the above rule, at least ignore the following:
-
-# User-specific stuff:
-# .idea/workspace.xml
-# .idea/tasks.xml
-# .idea/dictionaries
-
-# Sensitive or high-churn files:
-# .idea/dataSources.ids
-# .idea/dataSources.xml
-# .idea/sqlDataSources.xml
-# .idea/dynamic.xml
-# .idea/uiDesigner.xml
-
-# Gradle:
-# .idea/gradle.xml
-# .idea/libraries
-
-# Mongo Explorer plugin:
-# .idea/mongoSettings.xml
-
-## File-based project format:
-*.ipr
-*.iws
-
-## Plugin-specific files:
-
-# IntelliJ
-out/
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-
-
-### Yeoman template
-node_modules/
-bower_components/
-*.log
-
-build/
-dist/
-
-
diff --git a/www/lib/ng-facebook/.travis.yml b/www/lib/ng-facebook/.travis.yml
deleted file mode 100644
index db7bb8a..0000000
--- a/www/lib/ng-facebook/.travis.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-language: node_js
-node_js:
- - "0.10"
-
-env:
- global:
- - SAUCE_USERNAME=ngFacebook
- - SAUCE_ACCESS_KEY=da67f9c2-bb80-424b-8879-cac1feae30cd
-
-addons:
- sauce_connect: true
-
-install:
- - npm install
- - npm install protractor cucumber bower -g
- - npm install lodash
- - bower install
-
-script:
- - node test/scripts/web-server.js &
- - sleep 1 # give the server some time to get his things... drink coffee.. and such
- - protractor
\ No newline at end of file
diff --git a/www/lib/ng-facebook/README.md b/www/lib/ng-facebook/README.md
deleted file mode 100644
index 7ea013c..0000000
--- a/www/lib/ng-facebook/README.md
+++ /dev/null
@@ -1,143 +0,0 @@
-Angular Facebook [](https://travis-ci.org/GoDisco/ngFacebook)
-==================
-Angular service to handle facebook
-
-Installation
-------------
-1. Download the package:
- 1. download using npm: `npm install ng-facebook`
- 1. download using the [zip file](https://github.com/GoDisco/ngFacebook/archive/master.zip)
- 1. download using bower: `bower install ng-facebook`
-1. Modify your application to include `ngFacebook` in your application dependencies
-1. Configure the ngFacebook module using the configuration steps outlined in the section titled "Configuration" below.
-1. Load the [*Facebook SDK for javascript*](https://developers.facebook.com/docs/reference/javascript/), **BUT DO NOT** call `FB.init` or set `window.fbAsyncInit`. These steps are automatically done by the ngFacebook module.
-
-Example:
-
-```javascript
-angular.module('', ['ngFacebook'])
-
-.config( function( $facebookProvider ) {
- $facebookProvider.setAppId('');
-})
-
-.run( function( $rootScope ) {
- // Cut and paste the "Load the SDK" code from the facebook javascript sdk page.
-
- // Load the facebook SDK asynchronously
- (function(){
- ...
- }());
-})
-
-;
-
-var DemoCtrl = function ($scope, $facebook) {
- ...
- function refresh() {
- $facebook.api("/me").then(
- function(response) {
- $scope.welcomeMsg = "Welcome " + response.name;
- },
- function(err) {
- $scope.welcomeMsg = "Please log in";
- });
- }
-};
-
-```
-
-For more details check out this [plunker which uses ngFacebook](http://plnkr.co/edit/HcYBFKbqFcgQGhyCGQMw?p=preview).
-
-Configuration
------
-You *must* configure your `facebook application ID` in your app, for example:
-
- app.config(function(FacebookProvider) {
- $facebookProvider.setAppId(11111111111);
- });
-
-### Additional configurations
-You can also configure the following properties. Both `set` and `get` methods are available for each property.
-
-
-1. `permissions()` - permissions required by your app.
-
- Example:
-
- $facebookProvider.setPermissions("email,user_likes");
-
-1. `customInit()` - the parameters to pass to `FB.init()`. The 'appId' parameter is automatically specified using the value passed to '$facebookProvider.setAppId()', however the remaining parameters are configurable.
-
- Example to set:
-
- $facebookProvider.setCustomInit({
- channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html',
- xfbml : true
- });
-
-1. `version()` - specify the version of the api (_v1.0 by default_).
-
- Example to set:
-
- $facebookProvider.setVersion("v2.2");
-
-
-Using
------
-### Methods
-1. `$facebook.config(property)` - Return the config property.
-1. `$facebook.getAuthResponse()` - Return the `AuthResponse`(assuming you already connected)
-1. `$facebook.getLoginStatus()` - Return *promise* of the result.
-1. `$facebook.login()` - Logged in to your app by facebook. Return *promise* of the result.
-1. `$facebook.logout()` - Logged out from facebook. Return *promise* of the result.
-1. `$facebook.ui(params)` - Do UI action(see facebook sdk docs). Return *promise* of the result.
-1. `$facebook.api(args...)` - Do API action(see facebook sdk docs). Return *promise* of the result.
-1. `$facebook.cachedApi(args...)` - Do API action(see above), but the result will cached. Return *promise* of the result.
-1. `$facebook.setVersion(version)` - Set another SDK version
-1. `$facebook.getVersion()` - Get current SDK version
- Example:
-
- app.controller('indexCtrl', function($scope, $facebook) {
- $scope.user=$facebook.cachedApi('/me');
- });
-
-### Events
-The service will broadcast the facebook sdk events with the prefix `fb.`.
-
-In return you will get the next arguments to your `$on` handler: `event,response,FB` (`FB` is the facebook native js sdk).
-
-1. `fb.auth.login`
-1. `fb.auth.logout`
-1. `fb.auth.prompt`
-1. `fb.auth.sessionChange`
-1. `fb.auth.statusChange`
-1. `fb.auth.authResponseChange`
-1. `fb.xfbml.render`
-1. `fb.edge.create`
-1. `fb.edge.remove`
-1. `fb.comment.create`
-1. `fb.comment.remove`
-1. `fb.message.send`
-
-*For additional information about the events see the sdk docs.*
-
-License
---------
-This project is released over [MIT license](http://opensource.org/licenses/MIT "MIT License")
-
-
-Sponsors
-------
-Thanks to our sponsors for this project:
-
-1. [GoDisco](http://www.godisco.net)
-1. [JetBrains](http://www.jetbrains.com/) - for providing the great IDE [PhpStorm](http://www.jetbrains.com/phpstorm/)
-
-
-Authors
--------
-
-1. [Almog Baku](http://www.AlmogBaku.com "AlmogBaku") - by [GoDisco](http://www.godisco.net)
-1. [Amir Valiani](https://github.com/avaliani "Avaliani")
-1. [Tal Gleichger](http://gleichger.com/ "talgleichger") - by [GoDisco](http://www.godisco.net)
diff --git a/www/lib/ng-facebook/bower.json b/www/lib/ng-facebook/bower.json
deleted file mode 100644
index 37e7a69..0000000
--- a/www/lib/ng-facebook/bower.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "name": "ng-facebook",
- "main": "ngFacebook.js",
- "version": "0.1.6",
- "homepage": "https://github.com/GoDisco/ngFacebook",
- "authors": [
- "AlmogBaku "
- ],
- "description": "Angular service to handle facebook api",
- "keywords": [
- "facebook",
- "facebook-api",
- "service",
- "angularjs",
- "angular",
- "ngFacebook",
- "api",
- "facebook-sdk",
- "sdk"
- ],
- "license": "MIT",
- "dependencies": {
- "angular": ">=1.0.0 <2.0.0"
- }
-}
diff --git a/www/lib/ng-facebook/ngFacebook.js b/www/lib/ng-facebook/ngFacebook.js
deleted file mode 100644
index 02723df..0000000
--- a/www/lib/ng-facebook/ngFacebook.js
+++ /dev/null
@@ -1,244 +0,0 @@
-/**
- * Angular Facebook service
- * ---------------------------
- *
- * Authored by AlmogBaku (GoDisco)
- * almog@GoDisco.net
- * http://www.GoDisco.net/
- *
- * 9/8/13 10:25 PM
- */
-
-angular.module('ngFacebook', [])
- .provider('$facebook', function() {
- var config = {
- permissions: 'email',
- appId: null,
- version: 'v1.0',
- customInit: {}
- };
-
- this.setAppId = function(appId) {
- config.appId=appId;
- return this;
- };
- this.getAppId = function() {
- return config.appId;
- };
- this.setVersion = function(version) {
- config.version=version;
- return this;
- };
- this.getVersion = function() {
- return config.version;
- };
- this.setPermissions = function(permissions) {
- if(permissions instanceof Array) {
- permissions.join(',');
- }
- config.permissions=permissions;
- return this;
- };
- this.getPermissions = function() {
- return config.permissions;
- };
- this.setCustomInit = function(customInit) {
- if(angular.isDefined(customInit.appId)) {
- this.setAppId(customInit.appId);
- }
- config.customInit=customInit;
- return this;
- };
- this.getCustomInit = function() {
- return config.customInit;
- };
-
- this.$get = ['$q', '$rootScope', '$window', function($q, $rootScope, $window) {
- var $facebook=$q.defer();
- $facebook.config = function(property) {
- return config[property];
- };
-
- //Initialization
- $facebook.init = function() {
- if($facebook.config('appId')==null)
- throw "$facebookProvider: `appId` cannot be null";
-
- $window.FB.init(
- angular.extend({ appId: $facebook.config('appId'), version: $facebook.config('version') }, $facebook.config("customInit"))
- );
- $rootScope.$broadcast("fb.load", $window.FB);
- };
-
- $rootScope.$on("fb.load", function(e, FB) {
- $facebook.resolve(FB);
-
- //Define action events
- angular.forEach([
- 'auth.login', 'auth.logout', 'auth.prompt',
- 'auth.sessionChange', 'auth.statusChange', 'auth.authResponseChange',
- 'xfbml.render', 'edge.create', 'edge.remove', 'comment.create',
- 'comment.remove', 'message.send'
- ],function(event) {
- FB.Event.subscribe(event, function(response) {
- $rootScope.$broadcast("fb."+event, response, FB);
- if(!$rootScope.$$phase) $rootScope.$apply();
- });
- });
-
- // Make sure 'fb.auth.authResponseChange' fires even if the user is not logged in.
- $facebook.getLoginStatus();
- });
-
- /**
- * Internal cache
- */
- $facebook._cache={};
- $facebook.setCache = function(attr,val) {
- $facebook._cache[attr]=val;
- };
- $facebook.getCache = function(attr) {
- if(angular.isUndefined($facebook._cache[attr])) return false;
- return $facebook._cache[attr];
- };
- $facebook.clearCache = function() {
- $facebook._cache = {};
- };
-
- /**
- * Authentication
- */
-
- var firstAuthResp=$q.defer();
- var firstAuthRespReceived=false;
- function resolveFirstAuthResp(FB) {
- if (!firstAuthRespReceived) {
- firstAuthRespReceived=true;
- firstAuthResp.resolve(FB);
- }
- }
-
- $facebook.setCache("connected", null);
- $facebook.isConnected = function() {
- return $facebook.getCache("connected");
- };
- $rootScope.$on("fb.auth.authResponseChange", function(event, response, FB) {
- $facebook.clearCache();
-
- if(response.status=="connected") {
- $facebook.setCache("connected", true);
- } else {
- $facebook.setCache("connected", false);
- }
- resolveFirstAuthResp(FB);
- });
-
- $facebook.getAuthResponse = function () {
- return FB.getAuthResponse();
- };
- $facebook.getLoginStatus = function (force) {
- var deferred=$q.defer();
-
- return $facebook.promise.then(function(FB) {
- FB.getLoginStatus(function(response) {
- if(response.error) deferred.reject(response.error);
- else {
- deferred.resolve(response);
- if($facebook.isConnected()==null)
- $rootScope.$broadcast("fb.auth.authResponseChange", response, FB);
- }
- if(!$rootScope.$$phase) $rootScope.$apply();
- }, force);
- return deferred.promise;
- });
- };
- $facebook.login = function (permissions, rerequest) {
- if(permissions==undefined) permissions=$facebook.config("permissions");
- var deferred=$q.defer();
-
- var loginOptions = { scope: permissions };
- if (rerequest) {
- loginOptions.auth_type = 'rerequest';
- }
-
- return $facebook.promise.then(function(FB) {
- FB.login(function(response) {
- if(response.error) deferred.reject(response.error);
- else deferred.resolve(response);
- if(!$rootScope.$$phase) $rootScope.$apply();
- }, loginOptions);
- return deferred.promise;
- });
- };
- $facebook.logout = function () {
- var deferred=$q.defer();
-
- return $facebook.promise.then(function(FB) {
- FB.logout(function(response) {
- if(response.error) deferred.reject(response.error);
- else deferred.resolve(response);
- if(!$rootScope.$$phase) $rootScope.$apply();
- });
- return deferred.promise;
- });
- };
- $facebook.ui = function (params) {
- var deferred=$q.defer();
-
- return $facebook.promise.then(function(FB) {
- FB.ui(params, function(response) {
- if(response && response.error_code) {
- deferred.reject(response.error_message);
- } else {
- deferred.resolve(response);
- }
- if(!$rootScope.$$phase) $rootScope.$apply();
- });
- return deferred.promise;
- });
- };
- $facebook.api = function () {
- var deferred=$q.defer();
- var args=arguments;
- args[args.length++] = function(response) {
- if(response.error) deferred.reject(response.error);
- if(response.error_msg) deferred.reject(response);
- else deferred.resolve(response);
- if(!$rootScope.$$phase) $rootScope.$apply();
- };
-
- return firstAuthResp.promise.then(function(FB) {
- FB.api.apply(FB, args);
- return deferred.promise;
- });
- };
-
- /**
- * API cached request - cached request api with promise
- *
- * @param path
- * @returns $q.defer.promise
- */
- $facebook.cachedApi = function() {
- if(typeof arguments[0] !== 'string')
- throw "$facebook.cacheApi can works only with graph requests!";
-
- var promise = $facebook.getCache(arguments[0]);
- if(promise) return promise;
-
- var result = $facebook.api.apply($facebook, arguments);
- $facebook.setCache(arguments[0], result);
-
- return result;
- };
-
- return $facebook;
- }];
- })
- .run(['$rootScope', '$window', '$facebook', function($rootScope, $window, $facebook) {
- $window.fbAsyncInit = function() {
- $facebook.init();
- if(!$rootScope.$$phase) $rootScope.$apply();
- };
- }])
-;
diff --git a/www/lib/ng-facebook/package.json b/www/lib/ng-facebook/package.json
deleted file mode 100644
index 6cd07cd..0000000
--- a/www/lib/ng-facebook/package.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "name": "ng-facebook",
- "version": "0.1.6",
- "description": "Angular service to handle facebook api",
- "main": "ngFacebook.js",
- "repository": {
- "type": "git",
- "url": "https://github.com/GoDisco/ngFacebook.git"
- },
- "keywords": [
- "facebook",
- "angularjs",
- "service",
- "ng-facebook",
- "ngFacebook"
- ],
- "author": "@AlmogBaku (by GoDisco)",
- "license": "MIT License",
- "bugs": {
- "url": "https://github.com/GoDisco/ngFacebook/issues"
- },
- "homepage": "https://github.com/GoDisco/ngFacebook",
- "devDependencies": {
- "express": "~4.10.6",
- "chai": "~1.10.0",
- "chai-as-promised": "~4.1.1"
- },
- "scripts": {
- "test": "protractor"
- }
-}
diff --git a/www/lib/ng-facebook/protractor.conf.js b/www/lib/ng-facebook/protractor.conf.js
deleted file mode 100644
index 06eeb44..0000000
--- a/www/lib/ng-facebook/protractor.conf.js
+++ /dev/null
@@ -1,24 +0,0 @@
-exports.config = {
- seleniumAddress: 'http://localhost:4444/wd/hub',
- baseUrl: 'http://localhost:'+(process.env.HTTP_PORT || 8081)+'/test/',
- framework: 'cucumber',
- specs: [
- 'test/features/*.feature'
- ],
- cucumberOpts: {
- require: 'test/specs/*.js',
- format: 'pretty'
- },
- sauceUser: process.env.SAUCE_USERNAME,
- sauceKey: process.env.SAUCE_ACCESS_KEY,
- capabilities: {
- 'browserName': (process.env.TEST_BROWSER_NAME || 'chrome'),
- 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
- 'build': process.env.TRAVIS_BUILD_NUMBER,
- 'name': 'ngFacebook Tests'
- }
-};
-
-if(process.env.TRAVIS_BUILD_NUMBER) {
- delete exports.config.seleniumAddress;
-}
\ No newline at end of file
diff --git a/www/lib/ng-facebook/test/features/ngFacebook.feature b/www/lib/ng-facebook/test/features/ngFacebook.feature
deleted file mode 100644
index 664e800..0000000
--- a/www/lib/ng-facebook/test/features/ngFacebook.feature
+++ /dev/null
@@ -1,12 +0,0 @@
-Feature: ngFacebook
- Scenario: Facebook load
- Given angular webpage with ngFacebook
- Then facebook sdk should be loaded
- Scenario: Login
- Given an anonymous state
- When I login with facebook user "charlie_hportxj_chaplin@tfbnw.net" with password "1234"
- Then I should be logged in
- Then my name is "Charlie Chaplin"
- Scenario: cachedApi- friends list
- When I getting the list of my friends
- Then I should see "Marilyn Monroe" as a friend of mine
\ No newline at end of file
diff --git a/www/lib/ng-facebook/test/index.html b/www/lib/ng-facebook/test/index.html
deleted file mode 100644
index 2f7f01d..0000000
--- a/www/lib/ng-facebook/test/index.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- ngFacebook tests
-
-
Login
-
- Logout
- Login
-
-
- You are Logged in as {{user.first_name}} {{user.last_name}}
-
-
- You are not logged in.
-
-
-
-
Friends via cachedApi:
-
Get friends
-
-
-
-
\ No newline at end of file
diff --git a/www/lib/ng-facebook/test/index.js b/www/lib/ng-facebook/test/index.js
deleted file mode 100644
index b2f0598..0000000
--- a/www/lib/ng-facebook/test/index.js
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Authored by AlmogBaku
- * almog.baku@gmail.com
- * http://www.almogbaku.com/
- *
- * 27/12/14 21:01
- */
-
-angular.module('myApp', ['ngFacebook'])
- .config(['$facebookProvider', function($facebookProvider) {
- $facebookProvider.setAppId('764262530321266').setPermissions(['email','user_friends']);
- }])
- .run(['$rootScope', '$window', function($rootScope, $window) {
- (function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/en_US/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- $rootScope.$on('fb.load', function() {
- $window.dispatchEvent(new Event('fb.load'));
- });
- }])
- .controller('myCtrl', ['$scope', '$facebook', function($scope, $facebook) {
- $scope.$on('fb.auth.authResponseChange', function() {
- $scope.status = $facebook.isConnected();
- if($scope.status) {
- $facebook.api('/me').then(function(user) {
- $scope.user = user;
- });
- }
- });
-
- $scope.loginToggle = function() {
- if($scope.status) {
- $facebook.logout();
- } else {
- $facebook.login();
- }
- };
-
- $scope.getFriends = function() {
- if(!$scope.status) return;
- $facebook.cachedApi('/me/friends').then(function(friends) {
- $scope.friends = friends.data;
- });
- }
- }])
-;
\ No newline at end of file
diff --git a/www/lib/ng-facebook/test/scripts/web-server.js b/www/lib/ng-facebook/test/scripts/web-server.js
deleted file mode 100644
index 0307650..0000000
--- a/www/lib/ng-facebook/test/scripts/web-server.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Authored by AlmogBaku
- * almog.baku@gmail.com
- * http://www.almogbaku.com/
- *
- * 27/12/14 21:20
- */
-
-var express = require('express');
-var app = express();
-
-app.use(express.static(__dirname+'/../..'));
-
-var port = process.env.HTTP_PORT || 8081;
-app.listen(port, function () {
- var host = (process.env.HTTP_HOST || this.address().address);
-
- console.log('Example app listening at http://%s:%s/test/', host, port);
-});
\ No newline at end of file
diff --git a/www/lib/ng-facebook/test/specs/def.js b/www/lib/ng-facebook/test/specs/def.js
deleted file mode 100644
index afb2227..0000000
--- a/www/lib/ng-facebook/test/specs/def.js
+++ /dev/null
@@ -1,105 +0,0 @@
-// Use the external Chai As Promised to deal with resolving promises in expectations.
-var chai = require('chai');
-var chaiAsPromised = require('chai-as-promised');
-chai.use(chaiAsPromised);
-
-var expect = chai.expect;
-
-// Chai expect().to.exist syntax makes default jshint unhappy.
-// jshint expr:true
-
-module.exports = function() {
- this.Given('angular webpage with ngFacebook', function(next) {
- browser.get('index.html');
- next();
- });
- this.Then('facebook sdk should be loaded', function(next) {
- var fbRoot = by.id('fb-root');
- browser.wait(function() {
- return browser.driver.isElementPresent(fbRoot);
- }, 10000);
- browser.driver.isElementPresent(fbRoot).then(function(exists) {
- expect(exists).to.equal(true);
- });
- next();
- });
-
- this.Given('an anonymous state', function(next) {
- browser.driver.executeScript(function() {
- window.addEventListener('fb.load', function () {
- window.FB.logout();
- });
- }).then(function() {
- setTimeout(function() {
- next();
- }, 1000);
- });
- });
- this.When('I login with facebook user "$user" with password "$pass"', function(user, pass, next) {
- var parentWindow;
- element(by.id('login-btn')).click()
- .then(browser.getAllWindowHandles)
- .then(function(handles) {
- parentWindow = handles[0];
- return browser.switchTo().window(handles[1]);
- })
- .then(function() {
- browser.driver.findElement(by.id('email')).sendKeys(user);
- browser.driver.findElement(by.id('pass')).sendKeys(pass);
- return browser.driver.findElement(by.id('loginbutton')).click();
- })
- .then(browser.getAllWindowHandles)
- .then(function(handles){
- var deferred = protractor.promise.defer();
-
- if(handles.length===1) {
- deferred.fulfill();
- }
-
- //wait for window to be ready
- setTimeout(function() {
- browser.driver.isElementPresent(by.id('platformDialogForm')).then(function (exists) {
- if (exists) {
- deferred.fulfill(browser.driver.findElement(by.css('button[name=__CONFIRM__]')).click());
- } else {
- deferred.fulfill();
- }
- }).thenCatch(deferred.fulfill);
- }, 500);
-
- return deferred.promise;
- })
- .then(function() {
- return browser.switchTo().window(parentWindow);
- })
- .then(function() {
- setTimeout(next, 1000);
- });
- });
- this.Then('I should be logged in', function(next) {
- element(by.id('login-btn')).getText().then(function(text) {
- expect(text).to.equal('Logout');
- });
- next();
- });
- this.Then('my name is "$fullname"', function(fullname, next) {
- element(by.css('.message')).getText().then(function(text) {
- expect(text).to.equal('You are Logged in as '+fullname);
- });
- next();
- });
-
- this.When('I getting the list of my friends', function(next) {
- element(by.id('friends-btn')).click()
- .then(function() {
- setTimeout(next, 1000)
- });
- });
- this.Then('I should see "$friend" as a friend of mine', function(friend, next) {
- element(by.id('friend-list')).getText().then(function(text) {
- var friendlist = text.split('\n')
- expect(friendlist).to.contain(friend);
- });
- next();
- });
-};
\ No newline at end of file
From c1331b4d6fdc9e1842fc21b1c9bc818532d677da Mon Sep 17 00:00:00 2001
From: Himanshu_Chandra
Date: Mon, 5 Jun 2017 16:46:20 +0530
Subject: [PATCH 2/4] login with mobile ready
---
www/js/controllers/login.js | 5 ++++-
www/templates/login.html | 4 ++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/www/js/controllers/login.js b/www/js/controllers/login.js
index c2bd97d..ce6e728 100644
--- a/www/js/controllers/login.js
+++ b/www/js/controllers/login.js
@@ -42,8 +42,11 @@ angular.module('appskeleton')
$window.location.reload();
$state.go("app.main");
}
+ else if(data.data.message==="conflict"){
+ $scope.result="Please specify country code if using Mobile number";
+ }
else if(data.data.message==="fail"){
- $scope.result="Wrong email or password";
+ $scope.result="Wrong Email/Username/Mobile or password";
}
else{
$scope.result="Error occurred! Try again later.";
diff --git a/www/templates/login.html b/www/templates/login.html
index fbe4c68..b79bd8f 100644
--- a/www/templates/login.html
+++ b/www/templates/login.html
@@ -10,10 +10,10 @@ Login
-
+
{{result}}
-
-
+
+
-
-
-
+
+
+
{{GoogleMessage}}
-
-
+
{{result}}
-
+
-
-
\ No newline at end of file
+
+
+ {{FacebookMessage}}
+
+
From 9e97f933f3844bb37486fa5801eeca44b249228e Mon Sep 17 00:00:00 2001
From: Himanshu_Chandra
Date: Sat, 6 Jan 2018 17:19:38 +0530
Subject: [PATCH 4/4] redirections fixed
---
www/js/controllers/appindex.js | 19 +++++-
www/js/controllers/login.js | 15 +++--
www/js/controllers/profile.js | 110 ++++++++++-----------------------
www/js/controllers/signup.js | 37 ++++++-----
www/js/services/appindex.js | 20 +++---
5 files changed, 87 insertions(+), 114 deletions(-)
diff --git a/www/js/controllers/appindex.js b/www/js/controllers/appindex.js
index eeba0c8..d2b4312 100644
--- a/www/js/controllers/appindex.js
+++ b/www/js/controllers/appindex.js
@@ -8,12 +8,26 @@
* Controller of the appskeleton
*/
angular.module('appskeleton')
- .controller('AppindexCtrl', function ($scope,appindex,$window,$state,$ionicPopup,$timeout) {
+ .controller('AppindexCtrl', function ($scope,appindex,$window,$state,$ionicPopup,$timeout,$rootScope) {
$scope.loginStatus="Checking...";
$scope.ActivationMessage=undefined;
+ $scope.autoRedirect = function () {
+ var currUrl = $state.current.url;
+ if (appindex.loaded === true && appindex.loggedIn === true) {
+ if (currUrl === '/login' || currUrl === '/signup') {
+ $state.go("app.profile");
+ }
+ }
+ else if (appindex.loaded === true && appindex.loggedIn != true) {
+ if (currUrl === '/profile' || currUrl === '/appointments' || currUrl === '/opsdashboard' || currUrl === '/storedashboard') {
+ $state.go("app.login");
+ }
+ }
+ };
+
$scope.loadData=function(){
var promise = appindex.checkStatus();
promise.then(function(data){
@@ -29,11 +43,14 @@ angular.module('appskeleton')
}
$scope.loggedOut=true;
$scope.loggedIn=false;
+ appindex.loggedIn = true;
}
else{
$scope.loginStatus="Login/SignUp";
}
appindex.needReload=false;
+ appindex.loaded = true;
+ $scope.autoRedirect();
});
};
diff --git a/www/js/controllers/login.js b/www/js/controllers/login.js
index ce6e728..29c6c75 100644
--- a/www/js/controllers/login.js
+++ b/www/js/controllers/login.js
@@ -8,13 +8,13 @@
* Controller of the appskeleton
*/
angular.module('appskeleton')
- .controller('LoginCtrl', function ($scope,login,$window,$state,md5) {
+ .controller('LoginCtrl', function ($scope,login,$window,$state,md5,appindex) {
$scope.login={
loginid:"",
loginpassword:"",
};
-
+
$scope.submitForm=function(loginForm){
if(loginForm.$valid){
$scope.result="Checking..";
@@ -24,10 +24,10 @@ angular.module('appskeleton')
$scope.result="Invalid info.";
}
};
-
-
+
+
$scope.doLogin=function(){
-
+
var hashLoginPassword=md5.createHash($scope.login.loginpassword);
var loginObject = {
@@ -39,8 +39,7 @@ angular.module('appskeleton')
promise.then(function(data){
if(data.data.message==="success"){
$scope.result="Logged in successfully";
- $window.location.reload();
- $state.go("app.main");
+ appindex.needReload = true;
}
else if(data.data.message==="conflict"){
$scope.result="Please specify country code if using Mobile number";
@@ -55,5 +54,5 @@ angular.module('appskeleton')
$scope.result = "Error occurred! Try again later.";
});
};
-
+
});
diff --git a/www/js/controllers/profile.js b/www/js/controllers/profile.js
index 080ccb2..ece63c3 100644
--- a/www/js/controllers/profile.js
+++ b/www/js/controllers/profile.js
@@ -10,11 +10,6 @@
angular.module('appskeleton')
.controller('ProfileCtrl', function ($scope,$window,$state,appindex,profile,md5,$localStorage,$timeout) {
- if($localStorage.sessionid===undefined){
- $window.location.reload();
- $state.go("app.login");
- }
-
$scope.profile={
newUsername:"",
newName:"",
@@ -39,7 +34,7 @@ angular.module('appskeleton')
$scope.EditUsername="Edit Username";
-//////Loading data from index service
+//////Loading data from index service
$scope.loadData=function(){
if(appindex.userData.useremail!=undefined){
var print=appindex.userData;
@@ -60,60 +55,21 @@ angular.module('appskeleton')
$scope.FillPlaceholders();
}
}
- else{
- $window.location.reload();
- $state.go("app.login");
- }
};
- $scope.$watch(function(){return appindex.userData},function(newValue,oldValue){
- if(!angular.equals(appindex.userData, {})){
- $scope.loadData();
- }
+ var unregister=$scope.$watch(appindex.loaded,function(newValue,oldValue){
+ if(!angular.equals(appindex.loaded, false)){
+ $scope.loadData();
+ unregister();
+ }
},true);
- /* Optional function to load profile data from session instead of index service
- $scope.checkLogin=function(){
-
- var promise = profile.getData();
- promise.then(function(data){
-
- var print=data.data;
- var userInfo=data.data.userinfo;
- if(print.useremail==undefined){
- $window.location.reload();
- $location.path("app/login");
- }
- else{
- $scope.Email=print.useremail;
- $scope.uName=print.username;
- if(print.mobile!=undefined){
- $scope.Mobile=print.mobile;
- }
- if(userInfo){
- $scope.Name=userInfo.fullname;
- $scope.Area=userInfo.area;
- $scope.City=userInfo.city;
- $scope.Pincode=userInfo.pincode;
- $scope.State=userInfo.state;
- $scope.Country=userInfo.country;
- $scope.FillPlaceholders();
- }
- }
- },function(error){
- $window.location.reload();
- $location.path("app/login");
- });
- };
- if($localStorage.sessionid===undefined){
- $window.location.reload();
- $location.path("app/login");
- }
- else{
- $scope.checkLogin();
- }
- */
+ $scope.$watch(function(){return appindex.userData},function(newValue,oldValue){
+ if(!angular.equals(appindex.userData, {})){
+ $scope.loadData();
+ }
+ },true);
//////////// Show-Hide form button logic ////////
$scope.ShowProfileForm=function(){
@@ -171,7 +127,7 @@ angular.module('appskeleton')
else{
$scope.UsernameForm=true;
$scope.EditUsername="Edit Username";
- }
+ }
};
///////////// Edit profile logic //////////////
@@ -179,12 +135,12 @@ angular.module('appskeleton')
$scope.profile.newName=$scope.Name;
$scope.profile.newArea=$scope.Area;
$scope.profile.newCity=$scope.City;
- $scope.profile.newPincode=$scope.Pincode;
+ $scope.profile.newPincode=$scope.Pincode;
$scope.profile.newState=$scope.State;
$scope.profile.newCountry=$scope.Country;
}
- $scope.submitProfileForm=function (profForm) {
+ $scope.submitProfileForm=function (profForm) {
if(profForm.$valid && $scope.profile.newCountry!=undefined){
$scope.ProfileResult="Saving";
$scope.changeProfile();
@@ -207,7 +163,7 @@ angular.module('appskeleton')
"pincode":$scope.profile.newPincode,
"country":country,
};
-
+
var promise=profile.updateProfileData(profileObject);
promise.then(function(data) {
if(data.data.message==="unknown"){
@@ -242,7 +198,7 @@ angular.module('appskeleton')
};
$scope.ChangeMobile=function(){
-
+
var MobileObject={
"CountryCode":"+"+$scope.profile.countryCode,
"MobileNumber":$scope.profile.newMobile,
@@ -262,13 +218,13 @@ angular.module('appskeleton')
}
},function(error) {
$scope.MobileMessage="Error! Try again later";
- });
+ });
};
$scope.submitCode=function(codeForm){
if(codeForm.$valid){
$scope.CodeMessage="Checking Code..";
- $scope.VerifyCode();
+ $scope.VerifyCode();
}
else{
$scope.CodeMessage="Enter valid code";
@@ -284,7 +240,7 @@ angular.module('appskeleton')
promise.then(function(data) {
if(data.data.message==="pass"){
$scope.CodeMessage="Verified & Updated";
- appindex.needReload=true;
+ appindex.needReload=true;
$state.transitionTo("app.profile",null, {reload: true});
}
else if(data.data.message==="fail"){
@@ -306,7 +262,7 @@ angular.module('appskeleton')
}
},function(error) {
$scope.CodeMessage="Error! Try again later";
- });
+ });
};
$scope.SendAgain=function(){
@@ -322,11 +278,11 @@ angular.module('appskeleton')
$scope.checkPassword=function(){
if($scope.profile.newPassword2!=undefined)
- {
+ {
if($scope.profile.newPassword===$scope.profile.newPassword2)
- {
+ {
$scope.PasswordMessage="Passwords match";
- arePasswordsSame=true;
+ arePasswordsSame=true;
}
else if($scope.profile.newPassword==undefined){
$scope.PasswordMessage=undefined;
@@ -348,7 +304,7 @@ angular.module('appskeleton')
$scope.PasswordResult="Enter correct passwords";
}
};
-
+
$scope.changePassword=function () {
var hashOldPassword=md5.createHash($scope.profile.oldPassword);
@@ -357,7 +313,7 @@ angular.module('appskeleton')
"oldpassword":hashOldPassword,
"password1":hashNewPassword,
};
-
+
var promise=profile.setNewPassword(passwordObject);
promise.then(function(data) {
if(data.data.message==="success"){
@@ -378,7 +334,7 @@ angular.module('appskeleton')
$scope.PasswordResult="Error occured! Try again later";
});
};
-
+
///////////// Change Username ////////////////
$scope.UsernameMessage=null;
var isUsernameNew=false;
@@ -401,7 +357,7 @@ angular.module('appskeleton')
var usernameObj = {
"username":$scope.profile.newUsername,
};
-
+
var promise = profile.checkUsername(usernameObj);
promise.then(function(data){
if(data.data.message==="found"){
@@ -411,7 +367,7 @@ angular.module('appskeleton')
$scope.UsernameMessage = "Nice Choice!";
isUsernameNew=true;
$scope.disableButton=false;
- }
+ }
},function(error){
$scope.UsernameMessage = "Error occured! Try again later";
});
@@ -419,7 +375,7 @@ angular.module('appskeleton')
$scope.submitUsernameForm=function(usernameForm){
-
+
if(usernameForm.$valid && isUsernameNew==true){
$scope.toggleButton=true;
$scope.UsernameResult="Checking username..";
@@ -431,7 +387,7 @@ angular.module('appskeleton')
};
$scope.ChangeUsername=function(){
-
+
var UsernameObject={
"Username":$scope.profile.newUsername
}
@@ -439,7 +395,7 @@ angular.module('appskeleton')
promise.then(function(data){
if(data.data.message==="success"){
$scope.UsernameResult="Username changed";
- appindex.needReload=true;
+ appindex.needReload=true;
$state.transitionTo("app.profile",null, {reload: true});
}
else if(data.data.message==="unknown"){
@@ -460,6 +416,6 @@ angular.module('appskeleton')
$scope.UsernameResult="Error occured!Try again Later";
});
};
-
-
+
+
});
diff --git a/www/js/controllers/signup.js b/www/js/controllers/signup.js
index 600b13c..6b21c9f 100644
--- a/www/js/controllers/signup.js
+++ b/www/js/controllers/signup.js
@@ -8,7 +8,7 @@
* Controller of the appskeleton
*/
angular.module('appskeleton')
- .controller('SignupCtrl',function ($scope,signup,$window,$state,md5) {
+ .controller('SignupCtrl',function ($scope,signup,$window,$state,md5,appindex) {
$scope.signup={
@@ -17,7 +17,7 @@ angular.module('appskeleton')
password1:"",
password2:""
};
-
+
////////////Checking if username exists//////////////
$scope.UsernameMessage=null;
var isUsernameNew=false;
@@ -39,7 +39,7 @@ angular.module('appskeleton')
var usernameObj = {
"username":$scope.signup.username,
};
-
+
var promise = signup.checkUsername(usernameObj);
promise.then(function(data){
if(data.data.message==="found"){
@@ -50,7 +50,7 @@ angular.module('appskeleton')
$scope.UsernameMessage = "Nice Choice!";
isUsernameNew=true;
$scope.enableRegister(regForm);
- }
+ }
},function(error){
$scope.UsernameMessage = "Error occured! Try again later";
});
@@ -72,14 +72,14 @@ angular.module('appskeleton')
$scope.checkp=function(regForm){
$scope.isNotValid=true;
if($scope.signup.password2!=undefined)
- {
+ {
if($scope.signup.password1===$scope.signup.password2)
- {
+ {
$scope.passtext="Passwords match";
- passverified=true;
+ passverified=true;
$scope.enableRegister(regForm);
}
-
+
else if($scope.signup.password1==undefined){
$scope.passtext="";
passverified=false;
@@ -90,8 +90,8 @@ angular.module('appskeleton')
}
}
};
-
-////////////////////Registering The user////////////////////////////////////
+
+////////////////////Registering The user////////////////////////////////////
$scope.submitForm=function(regForm){
if(regForm.$valid && passverified==true && isUsernameNew==true){
$scope.result = "Checking..";
@@ -101,10 +101,10 @@ angular.module('appskeleton')
$scope.result="Enter correct and full info";
}
};
-
-
+
+
$scope.doRegister=function(){
-
+
var hashPassword=md5.createHash($scope.signup.password1);
var userObject = {
@@ -113,25 +113,24 @@ angular.module('appskeleton')
"password1":hashPassword,
"role":"customer"
};
-
+
var promise = signup.registerUser(userObject);
promise.then(function(data){
if(data.data.message==="pass"){
$scope.result = "Registered Successfully";
- $window.location.reload();
- $state.go("app.main");
+ appindex.needReload = true;
}
else if(data.data.message==="usernameTaken"){
$scope.UsernameMessage = "Username Taken";
isUsernameNew=false;
$scope.result ="Sorry!The username is already taken";
- }
+ }
else if(data.data.message==="emailTaken"){
$scope.result ="Email already registered!";
- }
+ }
else{
$scope.result = "Error occured! Try again later";
- }
+ }
},function(error){
$scope.result = "Error occured! Try again later";
});
diff --git a/www/js/services/appindex.js b/www/js/services/appindex.js
index b1f0a0e..ac9710e 100644
--- a/www/js/services/appindex.js
+++ b/www/js/services/appindex.js
@@ -13,6 +13,8 @@ angular.module('appskeleton')
var object = {
needReload:true,
+ loaded:false,
+ loggedIn:false,
userData:{},
checkStatus:function(){
@@ -20,7 +22,7 @@ angular.module('appskeleton')
appCall:true,
sessionid:$localStorage.sessionid
}
- var defer = $q.defer();
+ var defer = $q.defer();
$http.post(requrl+'/webindex',statusObject)
.then(function(data){
if(data.data.sessionid!=undefined){
@@ -29,7 +31,7 @@ angular.module('appskeleton')
defer.resolve(data);
},function(error){
defer.reject(error);
- })
+ })
return defer.promise;
},
@@ -38,25 +40,25 @@ angular.module('appskeleton')
appCall:true,
sessionid:$localStorage.sessionid
}
- var defer = $q.defer();
+ var defer = $q.defer();
$http.post(requrl+'/sendActivationLink',linkObject)
.then(function(data){
defer.resolve(data);
},function(error){
defer.reject(error);
- })
+ })
return defer.promise;
},
-
+
logout:function(){
var logoutObject={
appCall:true,
sessionid:$localStorage.sessionid
}
-
- var defer = $q.defer();
+
+ var defer = $q.defer();
$http.post(requrl+'/logout',logoutObject)
.then(function(data){
@@ -65,11 +67,11 @@ angular.module('appskeleton')
defer.resolve(data);
},function(error){
defer.reject(error);
- })
+ })
return defer.promise;
}
};
return object;
-});
\ No newline at end of file
+});