8000 GitHub - yvesroos/angular-gapi-auth: The easiest way to use Google GAPI Auth with angularJS
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

yvesroos/angular-gapi-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Angular Google GAPI Auth

The easiest way to use Google GAPI Auth with angularJS. This module use Google APIs Client Library for JavaScript

Requirements

Installation

Download the latest release

<script type="text/javascript" src="/angular-gapi-auth/dist/angular-gapi-auth.min.js"></script>

Add dependency

var app = angular.module('myModule', ['angular-gapi-auth']);

Configuration

add config in root module

app.config(['GAuthProvider', function(GAuthProvider){
  GAuthProvider.apiKey('API KEY');
  GAuthProvider.clientId('CLIENT ID');
  GAuthProvider.scopes = ['https://www.googleapis.com/auth/gmail.readonly',
                          'https://www.googleapis.com/auth/gmail.compose',
                          'https://www.googleapis.com/auth/gmail.insert',
                          'https://www.googleapis.com/auth/gmail.labels',
                          'https://www.googleapis.com/auth/gmail.modify',
                          'https://www.googleapis.com/auth/gmail.send'];
  GAuthProvider.loginOnLoad(true);
}]);

Use

app.controller('myController', ['$scope', 'GAuth',
    function myController($scope, GAuth) {
      $scope.login = function(){
        GAuth.login().then(function(){
          console.log('logged');
        });
      }

      $scope.logout = function(){
        GAuth.logout().then(function(){
          console.log('quitted :,(');
        });
      }

      $scope.verifyStatus = function(){
        if(GAuth.isAuthenticated()) alert('LOGGED');
        else alert('NOT YET');
      }

      $scope.getToken = function(){
        alert(GAuth.getToken());
      }
    }
]);

TODO

  • Implement all GAPI services
  • get user info

About

The easiest way to use Google GAPI Auth with angularJS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0