0.2.3 • Published 10 years ago

hubot-googleapi v0.2.3

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

hubot-googleapi

A hubot script to use google APIs

Installation

Run

$ npm install hubot-googleapi --save

Add hubot-googleapi to external-scripts.json

Required environment variables

Variable nameDescriptionExample
HEROKU_URL or HUBOT_URLhttp://your-hubot.example.com
GOOGLE_API_CLIENT_IDCLIENT ID you created on Google Developers Console
GOOGLE_API_CLIENT_SECRETCLIENT SECRET you created on Google Developers Console
GOOGLE_API_SCOPESCSV scope names you want to useadsense.readonly,analytics.readonly

To get CLIENT ID and CLIENT SECRET,

  1. Create a project at API console.
  2. Enable APIs you want to use at API & auth > APIs.
  3. Go to APIs & auth > Credentials, and create new Client ID. AUTHORIZED REDIRECT URI should be YOUR_HUBOT_URL/auth/googleapi/callback.
  4. Go to Conesent screen, select EMAIL ADRESS and fill PRODUCT NAME. These are required to authorize.

Usage

Authorization

Authorize through OAuth2

en30> hubot googleapi auth
hubot> Authorize at http://your-hubot.example.com/auth/googleapi

Event

hubot-googleapi listens on googleapi:request events, and you can use Google APIs by emitting them.

# in your scripts
# https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/profiles/list
robot.emit "googleapi:request",
  service: "analytics"
  version: "v3"
  endpoint: "management.profiles.list"
  params:                               # parameters to pass to API
    accountId: '~all'
    webPropertyId: '~all'
  callback: (err, data)->               # node-style callback
    return console.log(err) if err
    console.log data.items.map((item)->
      "#{item.name} - #{item.websiteUrl}"
    ).join("\n")

service,version,endpoint,params,callback are required.

You can find service name on google/google-api-nodejs-client/apis. endpoint corresponds to method names of google/google-api-nodejs-client.

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago