message: hangouts chat: allow to use GOOGLE_APPLICATION_CREDENTIALS_DATA with json instead of a file // optimise
diff: @@ -159,13 +159,9 @@ 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'
  + scopes: 'https://www.googleapis.com/auth/chat.bot',
  + ...configuration.google_auth_params
  };
  google
  @@ -180,22 +176,6 @@ 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) {
  