Coder Social home page Coder Social logo

nggapi's Introduction

ngGAPI

ngGAPI is a Google APIs client for AngularJS.

Status

Currently Youtube, Google+, Google Calendar, and parts of Blogger and Google Drive are implemented. I'm working (as of 10/20/2013) in my spare time to support the rest of the APIs. Erik Isaksen is helping with this and an example app. Glad to spend some time pair programming with anyone else that wants to contribute. If you want to use ngGAPI but something is missing or doesn't work as expected, please submit an issue, or better yet a pull request. Thanks in advance!

Install

Bower is the quickest way to include ngGAPI in your project.

$ bower install https://github.com/christiansmith/ngGAPI.git --save

<script src="bower_components/ngGAPI/gapi.js"></script>

If you don't use Bower, just download gapi.js into your scripts directory.

$ curl -O https://raw.github.com/christiansmith/ngGAPI/master/gapi.js

<script src="your/js/path/gapi.js"></script>

ngGAPI requires Google API JavaScript client library

<script src="https://apis.google.com/js/client.js"></script>

Usage

Be sure to include "gapi" as a dependency in your main app module.

angular.module('myApp', ['gapi'])

After you register your app in the Google APIs Console, configure ngGAPI with credentials and whatever scopes you need for your app.

angular.module('myApp')
  .value('GoogleApp', {
    apiKey: 'YOUR_API_KEY',
    clientId: 'YOUR_CLIENT_ID',
    scopes: [
      // whatever scopes you need for your app, for example:
      'https://www.googleapis.com/auth/drive',
      'https://www.googleapis.com/auth/youtube',
      'https://www.googleapis.com/auth/userinfo.profile'
      // ...
    ]
  })

To use a specific service, inject it into your controllers by name. All GAPI methods return a promise.

angular.module('myApp')
  .controller('VideosCtrl', function ($scope, Youtube) {
    $scope.videos = Youtube.search({ part: 'snippet', q: 'Search terms' })
  });

Services

GAPI authorization

  • GAPI.init()

Drive

Youtube

Official Youtube DATA API (v3) reference documentation

Google+

Calendar API

Development

Installing the Karma test runner with npm install karma -g, then run the tests with karma start.

Copyright and License

The library is Copyright (c) 2013 Christian Smith, and distributed under the MIT License.

nggapi's People

Contributors

abs2g08 avatar christiansmith avatar nilo85 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nggapi's Issues

Logged in

Hello!
It's possible to check if user is logged in?

First time clicking button to do oauth triggers pop-up blocker

Not sure why this is happening, but this would be awful for our users to experience. Any tips on getting it to work properly the first time they click auth?

Google Auth

$scope.authorize = function () {
var promise = GAPI.init();
promise.then(function(data){
console.log("data", data);
var googleUser = Plus.searchPeople('me');
console.log("googleUser", googleUser);
});
};

Authenticate window on Android

Hi,

I am trying to use this in my ionic app.
In browser, i get the popup, but same thing never loads when I create an Android APK and test on my device. Any idea? I may be missing something?

Cannot read property 'access_token' of undefined

Error when trying to use GAPI.init();

Already checked if the value 'GoogleApp' is defined at the module level.

Tried the sample app wich uses ngDropbox and ngGapi, same problem. Not sure what to fix. Your help is appreciated.

TypeError: Youtube.search is not a function

Hi,

I get this errors and i don't get it :

TypeError: Youtube.search is not a function

My controller file :

'use strict';

var myapp = angular.module('teamc')
    .value('Youtube', {
        apiKey: 'AIzaSyBQ......msgl1LN8nQIo',
        scopes: [
          'https://www.googleapis.com/auth/youtube'
        ]
    })
    .controller('VideosCtrl', function ($scope, Youtube) {
        $scope.videos = Youtube.search({ part: 'snippet', q: 'sdfsdfsfd' });
        console.log($scope.videos);
    });

Any idea ?
"gapi" is also include as a dependency in my main app module. Installation with bower

Unknown provider: DriveProvider <- Drive <- VideoController

Following the boilerplate example, getting this console error:

Unknown provider: DriveProvider <- Drive <- VideoController

Following the boilerplate installation, got this output:

angular.js:14110 Error: [$injector:unpr] Unknown provider: DriveProvider <- Drive <- VideoController
http://errors.angularjs.org/1.5.9/$injector/unpr?p0=DriveProvider%20%3C-%20Drive%20%3C-%20VideoController
at angular.js:68
at angular.js:4554
at Object.getService [as get] (angular.js:4707)
at angular.js:4559
at getService (angular.js:4707)
at injectionArgs (angular.js:4732)
at Object.invoke (angular.js:4754)
at $controllerInit (angular.js:10518)
at nodeLinkFn (angular.js:9416)
at compositeLinkFn (angular.js:8757)

app.js

var app = angular.module('MyApp',['MyApp.services']);
angular.module('app', [
'angularGAPI'
]);

Not able to download via bower

When trying to import library using bower, I get the following issue:
Permission denied (publickey).
Please make sure you have the correct access rights
and the repository exists.

Login attempt failed. Attempted to login 4 times.

What's the cause of this? I'm with REST API's. Thank you and God Bless.

--EDIT

Yes I know now what's the cause of this but how does the user authorize the use of their Google account's data to be used within a website?

Unable to call init() on GAPI

Hi, I can't seem to initialize GAPI and I'm not sure why. I get this error message:

TypeError: Cannot read property 'authorize' of undefined
at Function.GAPI.init (gapi.js:404)
at new (main.min.js:303)
at invoke (angular.js:3720)
at Object.instantiate (angular.js:3731)
at angular.js:6848
at q (angular-ui-router.min.js:7)
at A (angular-ui-router.min.js:7)
at Scope.$broadcast (angular.js:12329)
at t.transition.N.then.t.transition.t.transition (angular-ui-router.min.js:7)
at wrappedCallback (angular.js:11033)

Here's the code from my controller:
routerApp.controller('home-controller', function($scope, GAPI, Calendar) { //debugger; GAPI.init(); var cal = Calendar.getCalendars('[email protected]');

I'm not sure if this is a bug or if I'm missing something obvious ๐Ÿ˜ณ.

Thanks!
Alistair

Secure apiKey & clientId

Hello,

I'm just starting to develop in AngularJS and I have a question(sorry if it's idiotic):
Is there a way to prevent the end user to find the aapiKey & clientId values from the js files?

Thanks.

adding "main":"gapi.js", to bower will help in auto injection

{
"name": "ngGAPI",
"version": "0.0.0",
"main":"gapi.js",
"ignore": [
"*/.",
"node_modules",
"components"
],
"devDependencies": {
"angular": "~1.0.7",
"angular-mocks": "~1.0.7",
"angular-mocks-unstable": "~1.1.5",
"angular-unstable": "1.1.5"
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.