hubot-googledrive-search
Search your google drive with hubot!
This is still a work in progress...
Installation
- In your project repo run:
npm install hubot-googledrive-search --save
- Then add the follwing to your external-scripts.json:
[
'hubot-googledrive-search'
]
Configuration
This script requires you to generate oauth2 credentials for the drive account that you want hubot to be able to access. Currently this scipt is configured to give hubot access to all of drive (the specific scope used is: 'https://www.googleapis.com/auth/drive').
- Generate a client secret.json file by following step 1 here: https://developers.google.com/drive/v2/web/quickstart/nodejs
- Set the environemnt variables that hubot needs (found in your client secret.json file):
- heroku config:add DRIVE_CLIENT_ID="your_client_id"
- heroku config:add DRIVE_CLIENT_SECRET="your_client_secret"
- heroku config:add DRIVE_REDIRECT_URL="the_first_uri_in_the_list"
- Load the script and attempt to interact with hubot. You will have to authorize the app to get your inital token and refresh token. The script will then store the refresh token in the hubot brain for future use, so this process should onlye need to be done once. Here's a sample interaction:
user>> @hubot drive search title= My Cool File
hubot>> Authorize this app by visiting: https://google.com/some_thing_with_your_client_info
Then use @hubot drive set code <code>
user>> @hubot drive set code 123412351235
hubot>> drive code successfully set
user>> @hubot search title= Cool File
hubot>> Name= This is a Cool File : https://google.drive/1234h123h4123h
Name= Some Cool File : https://google.drive/qwer1353451asfds
Features
This script can be used to search your drive in a variety of ways:
- Use a google query string to search drive. Find information on query strings here: https://developers.google.com/drive/v2/web/search-parameters
user>> @hubot drive search query= fullText contains 'important' and trashed = true
- Use either a title and/or a contains parameter. Equivalent query string shown below each example.
user>> @hubot drive search title= My Cool File
#equivalent to:
user>> @hubot drive search query= title contains 'My Cool File'
user>> @hubot drive search contains= This is the coolest file ever
#equivalent to:
user>> @hubot drive search query= fullText contains 'This is the coolest file ever'
user>> @hubot drive search title= My Cool File contains= This is the coolest file ever
#equivalent to:
user>> @hubot drive search query= title contains 'My Cool File' and fullText contains 'This is the coolest file ever'
Notes
Since hubot needs to use the redis brain to store the drive tokens and expiration time make sure that the following keys don't conflict with any other keys being used in the brain:
TOKEN_KEY = 'HUBOT_DRIVE_AUTH_TOKEN'
REFRESH_KEY = 'HUBOT_DRIVE_REFRESH_TOKEN'
EXPIRY_KEY = 'HUBOT_DRIVE_EXPIRE_TIME'