Code Monkey home page Code Monkey logo

meteor-google-api's Introduction

Google API

A Meteor library to interact with Google's API.

Works with accounts-google to automatically handle refresh/access token changes and give you a simple API to make calls.

Install

meteor add percolate:google-api

Usage

To call the library, use the get() and post() functions:

GoogleApi.get('/your/api/path', options[, callback]);

If callback is provided (client or server), the call will be made asynchronously.

Available methods: GoogleApi.get, GoogleApi.post, GoogleApi.patch, GoogleApi.put, GoogleApi.delete

GoogleApi is a Google OAuth authentication wrapper around HTTP, so it takes the same arguments. For example, to pass a JSON body in GoogleApi.post, use:

GoogleApi.post('/your/api/path', { data: jsonBody });

On the client, if you do not provide a callback, the library will return a Q promise. On the server, it will run synchronously.

If the user's access token has expired, it will transparently call the exchangeRefreshToken method to get a new refresh token. To call this method manually (e.g. from other Google API packages), use Meteor.call('exchangeRefreshToken'[, userId]). You should first check that that the user's token has actually expired, though, since this method won't.

Tokens

If you are running client side or in a method call, the package will automatically use the OAuth access token of the current user, and use the refresh token to refresh it if it's out of date (saving to the database also).

If you are running from a context without a Meteor.user(), you can pass {user: X} in the options argument to achieve this behaviour.

Contributions

Are welcome.

MIT license, (c) Percolate Studio, maintained by Tom Coleman (@tmeasday).

meteor-google-api's People

Contributors

hexsprite avatar jiku avatar jon-mann avatar npvn avatar tmeasday avatar wizonesolutions avatar zol avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

versolearning

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.