A lightweight library to perform client side authentication with Google OAuth2.
###Installation
npm install angular-google-auth2 --save
Include this script in your index.html file before your application bundle
<script src="https://apis.google.com/js/platform.js"></script>
Configure your application
var app = angular.module('example', ['googleOAuth2']);
app.config(function (gapiAuth2CredentialsProvider) {
gapiAuth2CredentialsProvider.client_id = '<YOUR_CLIENT_ID>';
})
###Usage
####Directive
<google-sign-in width="250" height="50" longtitle="true" theme="light"></google-sign-in>
####Service
gapiAuth2
This is the simplest wrapper of Google library. For more information look at Client reference
There are only two methods:
- logout()
Returns promise
gapiAuth2.logout().then(function(){
console.log('logged out')
})
- getAuthInstance()
Gives access to the native methods. Returns promise
gapiAuth2.getAuthInstance().then(function(res){
console.log(res.instance.isSignedIn.get())
})
####Events
google:oauth2:signed-in
$rootScope.$on('google:oauth2:signed-in', function (e,val) {
console.log('is signed in', val)
})
google:oauth2:profile
$rootScope.$on('google:oauth2:profile', function (e,profile) {
console.log('got profile', profile)
})
###Contribution Feel free to extend functionality of this library if you need.