Skip to content
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

Google APIs Authentication Update #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
const {Adapter, User, TextMessage} = require.main.require('hubot/es2015');
const {PubSub} = require(`@google-cloud/pubsub`);
const {google} = require('googleapis');
const {auth} = require('google-auth-library');
const {HangoutsChatTextMessage, AddedToSpaceTextMessage, AddedToSpaceMessage, RemovedFromSpaceMessage, CardClickedMessage} = require('./message')

class HangoutsChatBot extends Adapter {
Expand All @@ -33,9 +32,12 @@ class HangoutsChatBot extends Adapter {

// Establish OAuth with Hangouts Chat. This is required for PubSub bots and
// HTTP bots which want to create async messages.
const authClientPromise = auth.getClient({
const googleauth = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/chat.bot']
});

const authClientPromise = Promise.resolve(googleauth);

this.chatPromise = authClientPromise.then((credentials) =>
google.chat({
version: 'v1',
Expand Down Expand Up @@ -255,7 +257,7 @@ class HangoutsChatBot extends Adapter {

/**
* Sets up adapter for communicating with Hangouts Chat. Hubot invokes this
* message during initialization. Need to always respond otherwise you'll see the
* message during initialization. Need to always respond otherwise you'll see the
* "hubot is not responding" message in chat.
*/
run() {
Expand Down