message: hangouts chat: allow to use GOOGLE_APPLICATION_CREDENTIALS_DATA with json instead of a file
diff: @@ -159,7 +159,11 @@ function GoogleHangoutsBot(configuration) {
  });
  google_hangouts_botkit.middleware.spawn.use(function(worker, next) {
  -
  + if(process.env.GOOGLE_APPLICATION_CREDENTIALS) {
  + /*
  + * if the env variable containing a json file path is present then do classic
  + * auth
  + */
  let params = {
  scopes: 'https://www.googleapis.com/auth/chat.bot'
  };
  @@ -176,6 +180,22 @@ function GoogleHangoutsBot(configuration) {
  console.error('Could not get google auth client !');
  throw new Error(err);
  });
  + }
  + else if(process.env.GOOGLE_APPLICATION_CREDENTIALS_DATA) {
  + // else we use the env containing the actual data
  + let keys = JSON.parse(process.env.GOOGLE_APPLICATION_CREDENTIALS_DATA);
  + let client = google.auth.fromJSON(keys);
  + client.scopes = ['https://www.googleapis.com/auth/chat.bot'];
  + worker.authClient = client;
  + worker.api = google.chat({
  + version: api_version,
  + auth: worker.authClient
  + });
  + next();
  + }
  + else {
  + throw new Error('Can\'t find GOOGLE_APPLICATION_CREDENTIALS or GOOGLE_APPLICATION_CREDENTIALS_DATA, auth failed');
  + }
  });
  google_hangouts_botkit.middleware.normalize.use(function handlePostback(bot, message, next) {
  