/ng-cordova-oauth-gatekeeper.js

ng-cordova-oauth-gatekeeper.js

Primary LanguageJavaScript

ng-cordova-oauth-gatekeeper.js

GitHub OAuth using Apache Cordova and the InAppBrowser plugin

GitHub's OAuth Web Application Flow is not safe enough in client side. So, there is a simple aagent gatekeeper, it will protect your client secret more secure.

This simple script is inspired by the ng-cordova-oauth, but it's just for GitHub, and just can be used with gatekeeper. So I created this rather than sending a PR to ng-cordova-oauth.

Install

$ bower install ng-cordova-gatekeeper --save

Prepare

Usage

angular.module('myApp', ['ngCordovaGatekeeper'])
  .controller('loginCtrl', function() {
    $scope.doLogin = function() {
      $cordovaGatekeeper.auth(client_id, scope, gatekeeperServer).then(function(result) {
        console.log(result)
      }, function(error) {
        console.log(error);
      })
    };
  })

Params

  • client_id: your github OAuth client id
  • scope: github OAuth scope array
  • gatekeeperServer: your gatekeeper server addr. should be like http://ip:9999/authenticate/

and

<form ng-submit="doLogin()">
  <button class="button button-positive" type="submit">
    Auth
  </button>
</form>

License

MIT @ Leigh Zhu