Skip to content

willscripted/goggles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image by Neil Turner

Goggles

Results are inconclusive. Looking directly at the init code of google's client api may result in irreversable eye damage.

Just promise me you'll load the api.

Install

bower install --save goggles

Usage

Include this on your page

var goggles = new Goggles({
  apiKey:   "SOME_API_KEY",
  clientId: "SOME_CLKENT_KEY"
  scope: [
    'https://www.googleapis.com/auth/calendar.readonly'
  ]
});

// Attach login to button if not automatically logged in
$("button .google").click(goggles.login)

The apiKey allows your app to access public data.
The clientId is the id that the user is authorizing to access their public data.
The scope is a set of permissions that the user is granting to the clientId.

// google api promise (goggles)
// returns the `gapi`
goggles.then(function(gapi){

  gapi.client.request({
    // request params
  }).execute(function(){});

});

API

Methods

then(fn)

Where fn is a function of signature function (googleApi)

login()

Method to prompt the user to allow oauth access.

Note - This must be done syncronously on a button click to prevent the popup from being blocked

Contributing

Specs please.

License

The MIT License (MIT)

Copyright (c) 2014 Will O'Brien