npm install hubot-googleapihubot-googleapi
================
A hubot script to use google APIs
``sh`
$ npm install hubot-googleapi --save
Add hubot-googleapi to external-scripts.json
Variable name | Description | Example
--------------------------- | ----------------------- | -----------------
HEROKU_URL or HUBOT_URL | | http://your-hubot.example.comGOOGLE_API_CLIENT_ID | CLIENT ID you created on Google Developers Console |GOOGLE_API_CLIENT_SECRET | CLIENT SECRET you created on Google Developers Console |GOOGLE_API_SCOPES | CSV scope names you want to use | adsense.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.APIs & auth > Credentials
3. Go to , and create new Client ID. AUTHORIZED REDIRECT URI should be YOUR_HUBOT_URL/auth/googleapi/callback.Conesent screen
4. Go to , select EMAIL ADRESS and fill PRODUCT NAME. These are required to authorize.
``
en30> hubot googleapi auth
hubot> Authorize at http://your-hubot.example.com/auth/googleapi
listens on googleapi:request events, and you can use Google APIs by emitting them.`coffee
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.