-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hangouts chat: allow to consume auth data from env var instead of file #1543
Conversation
…json instead of a file
I have also create a pull request on the dedicated starter project: howdyai/botkit-starter-googlehangouts#1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your contribution and for sharing your use case 👍
However, google auth library already offers a smart mechanism to load credentials from environment variables without using .fromJSON()
directly on our code to get a JWT, it did that for us inside auth.getClient
method.
.getClient()
method can create the correct credential type for us, depending upon the environment our code is running under. For example : a JWT auth client will be created when our code is running on ourr local developer machine, and a compute client will be created when the same code is running on Google Cloud Platform.
I propose something like that if you don't mind:
google_hangouts_botkit.middleware.spawn.use(function(worker, next) {
let params = {
scopes: 'https://www.googleapis.com/auth/chat.bot',
...configuration.google_auth_params
};
google
.auth
.getClient(params)
.then(client => {
...
})
.catch(err => {
...
});
});
var controller = Botkit.googlehangoutsbot({
endpoint: 'Axjn86rTGRQwisaYFyT0XZyiOCh7rZUPGx1A',
token: "YOUR_TOKEN",
debug: true,
google_auth_params: {
credentials: process.env['CREDS']
}
});
WDYT ?
Hello, will test that ASAP ! |
…json instead of a file // optimise
Great it work well ! I have also updated the PR of howdyai/botkit-starter-googlehangouts#1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you @bobman38
Instead of setting
GOOGLE_APPLICATION_CREDENTIALS
with the path of the json google auth file, this PR allow to useGOOGLE_APPLICATION_CREDENTIALS_DATA
that contains the actual json data. This idea come from here.It will allow to use botkit as a hangout chat bot on Heroku like systems.
You need to start botkit like that:
See issue #1533