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.
$ bower install ng-cordova-gatekeeper --save
- Apache Cordova 3.5+
- Apache Cordova InAppBrowser Plugin
- A gatekeeper server
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);
})
};
})
client_id
: your github OAuth client idscope
: github OAuth scope arraygatekeeperServer
: your gatekeeper server addr. should be likehttp://ip:9999/authenticate/
and
<form ng-submit="doLogin()">
<button class="button button-positive" type="submit">
Auth
</button>
</form>
MIT @ Leigh Zhu