All Projects → maximepvrt → Angular Google Gapi

maximepvrt / Angular Google Gapi

An AngularJS module for using all Google Apis and your Google Cloud Endpoints (Google App Engine) with OAuth. This module uses Google APIs Client Library for JavaScript, available for all GApis.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Angular Google Gapi

google-oauth2-web-client
Login with Google using OAuth2 for client-side web app
Stars: ✭ 32 (-81.82%)
Mutual labels:  oauth, google-api
Portfolio Generator
HoxNox - Portfolios Made Easy, Generate portfolios in 3 easy steps
Stars: ✭ 166 (-5.68%)
Mutual labels:  oauth
Fresh
🍋 A token refresh library for Dart.
Stars: ✭ 128 (-27.27%)
Mutual labels:  oauth
Google Places Api
This is a PHP wrapper for Google Places API Web Service. And is Laravel Framework friendly.
Stars: ✭ 147 (-16.48%)
Mutual labels:  google-api
Dashport
Local and OAuth authentication middleware for Deno
Stars: ✭ 131 (-25.57%)
Mutual labels:  oauth
Carmarker Animation
This android library will help to show the marker move along the route and turn smoothly along the road curves.
Stars: ✭ 154 (-12.5%)
Mutual labels:  google-api
Ng Gapi
ng-gapi a Google api module for Angular 6+
Stars: ✭ 126 (-28.41%)
Mutual labels:  google-api
Indieauth.com
This service is being discontinued in favor of indielogin.com
Stars: ✭ 172 (-2.27%)
Mutual labels:  oauth
Security.identity
.NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities
Stars: ✭ 165 (-6.25%)
Mutual labels:  oauth
Ngx Oauth
OAuth 2.0 proxy for nginx written in Lua.
Stars: ✭ 146 (-17.05%)
Mutual labels:  oauth
Monkey
Monkey is an unofficial GitHub client for iOS,to show the rank of coders and repositories.
Stars: ✭ 1,765 (+902.84%)
Mutual labels:  oauth
Cli
🧰 A zero trust swiss army knife for working with X509, OAuth, JWT, OATH OTP, etc.
Stars: ✭ 2,151 (+1122.16%)
Mutual labels:  oauth
Spark Pac4j
Security library for Sparkjava: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 154 (-12.5%)
Mutual labels:  oauth
React Google Autocomplete
React component for google autocomplete.
Stars: ✭ 131 (-25.57%)
Mutual labels:  google-api
Pac4j
Security engine for Java (authentication, authorization, multi frameworks): OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 2,097 (+1091.48%)
Mutual labels:  oauth
Giraffeql
🦒 Developer tool to visualize relational databases and export schemas for GraphQL API's.
Stars: ✭ 128 (-27.27%)
Mutual labels:  oauth
React Native Instagram Login
a react native instagram login component (support android & ios). Pull requests are welcome!
Stars: ✭ 139 (-21.02%)
Mutual labels:  oauth
Larapush
artisan push - Deploy your codebase into your web server with one Laravel artisan command and no SSH needed!
Stars: ✭ 150 (-14.77%)
Mutual labels:  oauth
Spring Boot Cloud
基于 Spring Boot、Spring Cloud、Spring Oauth2 和 Spring Cloud Netflix 等框架构建的微服务项目
Stars: ✭ 2,044 (+1061.36%)
Mutual labels:  oauth
Albert
这个是我个人网站的项目,欢迎贡献代码,力求能够应用到实际工作中java相关的大多数技术栈。有兴趣请Star一下,非常感谢。qq交流群:587577705 这个项目将不断地更新!生产环境:
Stars: ✭ 168 (-4.55%)
Mutual labels:  google-api

Angular Google GApi

Travis David npm Bower

An AngularJS module for using all Google Apis and your Google Cloud Endpoints (Google App Engine) with OAuth. This module uses Google APIs Client Library for JavaScript, available for all GApis.

Example

Demo

Code

Requirements

Installation

Add library

This module is available as bower package, install it with this command:

$ bower install --save angular-google-gapi

it's also available as a npm package, install it with this command:

$ npm install --save angular-google-gapi

or you may download the latest release

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

Add dependency

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

Configuration

without Google Auth

add run() in root module

app.run(['GApi', 'GAuth',
    function(GApi, GAuth) {
        var BASE = 'https://myGoogleAppEngine.appspot.com/_ah/api';
        GApi.load('myApiName', 'v1', BASE).then(function(resp) {
            console.log('api: ' + resp.api + ', version: ' + resp.version + ' loaded');
        }, function(resp) {
            console.log('an error occured during loading api: ' + resp.api + ', resp.version: ' + version);
        });
    }
]);

with Google Auth

add run() in root module

app.run(['GAuth', 'GApi', 'GData', '$state', '$rootScope',
    function(GAuth, GApi, GData, $state, $rootScope) {

        $rootScope.gdata = GData;

        var CLIENT = 'yourGoogleAuthAPIKey';
        var BASE = 'https://myGoogleAppEngine.appspot.com/_ah/api';

        GApi.load('myApiName','v1',BASE);
        GApi.load('calendar','v3'); // for google api (https://developers.google.com/apis-explorer/)

        GAuth.setClient(CLIENT)
        // default scope is only https://www.googleapis.com/auth/userinfo.email
        GAuth.setScope('https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/calendar.readonly');

        // load the auth api so that it doesn't have to be loaded asynchronously
        // when the user clicks the 'login' button.
        // That would lead to popup blockers blocking the auth window
        GAuth.load();

        // or just call checkAuth, which in turn does load the oauth api.
        // if you do that, GAuth.load(); is unnecessary
        GAuth.checkAuth().then(
            function (user) {
                console.log(user.name + ' is logged in');
                $state.go('webapp.home'); // an example of action if it's possible to
                			  	        // authenticate user at startup of the application
            },
            function() {
		        $state.go('login'); // an example of action if it's impossible to
					  	          // authenticate user at startup of the application
            }
        );
    }
]);

GApi.load Error handling

GApi.load('myApiName', 'v1', BASE)
   .catch(function(api, version) {
       console.log('an error occured during loading api: ' + api + ', version: ' + version);
   });

Usage

Execute your api without params

app.controller('myController', ['$scope', 'GApi',
    function myController($scope, GApi) {
        GApi.execute('youApi', 'you.api.method.name').then(function(resp) {
            $scope.value = resp;
        }, function() {
            console.log('error :(');
        });
    }
]);

Execute your api with params

app.controller('myController', ['$scope', 'GApi',
    function myController($scope, GApi) {
        GApi.execute('youApi', 'you.api.method.name', {param: value}).then(function(resp) {
            $scope.value = resp;
        }, function() {
            console.log('error :(');
        });
    }
]);

Execute your api without params with Google Auth

app.controller('myController', ['$scope', 'GApi',
    function myController($scope, GApi) {
         GApi.executeAuth('youApi', 'you.api.method.name').then(function(resp) {
            $scope.value = resp;
        }, function() {
            console.log('error :(');
        });
    }
]);

Execute your api with params with Google Auth

app.controller('myController', ['$scope', 'GApi',
    function myController($scope, GApi) {
        GApi.executeAuth('youApi', 'you.api.method.name', {param: value}).then(function(resp) {
            $scope.value = resp;
        }, function() {
            console.log('error :(');
        });
    }
]);

Signup with Google

The login should be triggered by a user action, or you might run into issues with popup blockers. More information about this can be found in the Google APIs Client Library Documentation.

app.controller('myController', ['$scope', 'GAuth', '$state',
    function myController($scope, GAuth, $state) {
        $scope.doSignup = function() {
            GAuth.login().then(function(user) {
                console.log(user.name + ' is logged in');
                $state.go('webapp.home'); // action after the user have validated that
        				                  // your application can access their Google account
            }, function() {
                console.log('login failed');
            });
        };
    }
]);

Get user info

Get user info after login is very simple

app.controller('myController', ['$rootScope',
    function myController($rootScope) {
        console.log($rootScope.gdata.getUser().name);
    }
]);
<h1>{{gdata.getUser().name}}</h1>

User object:

  • email
  • picture (url)
  • id (Google id)
  • name (Google account name or email if don't exist)
  • link (link to Google+ page)

Development

gulp is used to minify angular-google-gapi.js (using Uglify). Execute npm install (requires Node.js and npm) to install the required packages.

Run gulp to generate a minified version (angular-google-gapi.min.js). Note that this requires gulp to be installed globally (via npm install -g gulp).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].