angular-social-login

0.0.1 • Public • Published

Angular Social Login (ngSocialLogin)

Angular Social Login module (for PhoneGap/Cordova)

Supported sites:

  • Google
  • Facebook

Requirements

Complete functionality only available in PhoneGap/Cordova applications with inAppBrowser plugin (https://github.com/apache/cordova-plugin-inappbrowser) installed.

Installation

via npm

npm install angular-social-login

via bower

bower install angular-social-login

configure installation

Include JS file:

<script src="/bower_components/angular-social-login/angular-social-login.js"></script>

Then include ngSocialLogin as a dependency for your app:

angular.module('myApp', ['ngSocialLogin']);

Configuration

Example

app.config(['$googleDefaultsProvider', '$facebookDefaultsProvider',
    function ($googleDefaultsProvider, $facebookDefaultsProvider) {
 
        $googleDefaultsProvider.useConfig({
            client_id: 'YOUR CLIENT ID',
            client_secret: 'YOUR CLIENT SECRET',
            scope: 'YOUR SCOPES, E.G.: https://www.googleapis.com/auth/userinfo.email'
        });
 
        $facebookDefaultsProvider.useConfig({
            client_id: 'YOUR APP ID',
            scope: 'YOUR SCOPES, E.G.: email,read_stream,publish_actions'
        });
 
}]);

Usage

Methods

  • $googleDefaultsProvider.useConfig(config)
  • $facebookDefaultsProvider.useConfig(config)
  • $googleAuth.getAuthURL(authConfig)
  • $googleAuth.getAccessToken(authCode, customConfig, customURL)
  • $facebookAuth.getAuthURL(authConfig)
  • $socialAuthCordova.loginGoogle(authConfig, customConfig, customURL)
  • $socialAuthCordova.loginFacebook(authConfig, customConfig, customURL)
  • $socialAuthCordov.login(site, authConfig, customConfig, customURL)

Params

  • config/authConfig:
{
    client_id: YOUR CLIENT ID,
    redirect_uri: REDIRECT URI,
    response_type: RESPONSE TYPE,
    scope: SCOPE
}
  • customConfig: override authConfig for accessToken request (e.g. client_secret, grant_type)
  • customURL: custom URL to call access token requests (e.g. server proxy)

Example

$socialAuthCordova.loginGoogle(authConfig, customConfig, customURL).then(function (res) {
    console.log(res.access_token);
}, function (error) {
    console.log(error);
});
 
$socialAuthCordova.loginFacebook(authConfig, customConfig, customURL).then(function (access_token) {
    console.log(access_token);
}, function (error) {
    console.log(error);
});

/angular-social-login/

    Package Sidebar

    Install

    npm i angular-social-login

    Weekly Downloads

    19

    Version

    0.0.1

    License

    MIT

    Last publish

    Collaborators

    • paldom