An angular JS implementation for authentication library "Account Kit" from Facebook.
1.0.0
Click http://l.sgoyal.net/accountkit to see running demo.
- Automatically loads account kit sdk and handles its callback.
- Support Promises
- login with sms
- login with email
npm install ng-account-kit
OR
bower install ng-account-kit
Step 1 Include script into your index.html file.
<script src="node_modules/ng-account-kit/dist/ng-account-kit.min.js"></script>
OR
<script src="bower_component/ng-account-kit/dist/ng-account-kit.min.js"></script>
Step 2 Add dependency to you app module
angular.module ("net.sgoyal.sample",['ngAccountKit'])
Step 3 Configure account kit using accountKitProvider
angular.module ("net.sgoyal.sample",['ngAccountKit'])
.config (function(accountKitProvider){
accountKitProvider.configure("YOUR_APP_ID", "VERSION_INFO(v1.0)", "RANDOM_NON_GUESSABLE_STRING_FOR_CSRF_SAFE_CHECK", "CALLBACK_URL");
});
// Callback url will be posted with response received from account kit request. You may want to handle this at your server side code.
Step 4 Use it
.controller("AppCtrl", function($scope, $accountKit) {
$scope.loginWithSMS = function() {
$accountKit.loginWithSMS()
.then(function(res) {
console.log(res)
});
};
$scope.loginWithEmail = function() {
$accountKit.loginWithEmail()
.then(function(res) {
console.log(res)
}, function(err) {
console.log(err);
});
};
});
- loginWithSMS (countryCode, phoneNumber)
- loginWithEmail (emailAddress)
Do you want to improve it? Sounds cool. Please drop me a line at [email protected]