htauth
A simple Angular module to abstract Social Login (Facebook, Twitter, Google, ...)
To see the library in action use this JSFiddle Demo (but attention, facebook login inside jsfiddle environment doesn't work properly if you use chrome).
Available Providers
Planned Providers
- Twitter (..future)
Install
You can install this package locally either with npm or bower
$ bower install htauth --save
$ npm instal htauth --save
You can also download and include the library file (full or minified) available in the /dist
directory.
Usage
Facebook Login Provider
Full Example
angular ;
Provider Configuration
Settings for provider configuration are described in Facebook Official Documentation (here and here).
facebookProvider.init(SettingsObject)
// Default settings are appId: false // specify your APP ID cookie: true locale: "en_US" status: true version: "v2.5" xfbml: false scope: "public_profile,email"
angular // include htauth as dependecy
Provider Instance API
facebook.login()
A Promise function that resolves when user correctly login to the App and reject if the user does not authorize your app or is not logged to facebbok.
angular // ...something ;
facebook.isLogged()
true if the user is logged in false otherwise
facebook.getAuthResponse()
get the AuthResponse Object coming from Facebook sdk (if the user is logged in)
facebook.getAccessToken()
get the accessToken (same as getAuthResponse().accessToken) if the user is logged in
Google Login Provider
Full Example
angular ;
Provider Configuration
Settings for provider configuration are described in Google Official Documentation (here).
// Default settings are the same as Google init client_id: false // specify your APP ID cookie_policy: 'single_host_origin' fetch_basic_profile: true // scope is profile, email scope: // optional if fetch_basic_profile is true
angular // include htauth as dependecy
Provider Instance API
google.login()
A Promise function that resolves when user correctly login to the App and reject if the user does not authorize your app or is not logged to google.
angular // ...something ;
google.isLogged()
true if the user is logged in false otherwise
google.getAuthResponse()
get the AuthResponse Object coming from Google sdk (if the user is logged in)
google.getIdToken()
get the id_token (same as getAuthResponse().id_token) if the user is logged in
Dev and Build
TODO
Test
TODO
License
MIT © Andrea Tarquini aka @h4t0n