module.exports = defineComponent({
props: {
google_chat_service_account_key: {
type: "app",
app: "google_chat_service_account_key",
}
},
async run({ steps, $ }) {
// Required workaround to get the @google-cloud/storage package
// working correctly on Pipedream
require("@dylburger/umask")();
const { google } = require("googleapis");
const key = JSON.parse(this.google_chat_service_account_key.$auth.key_json);
const auth = new google.auth.JWT({
email: key.client_email,
key: key.private_key,
scopes: ["https://www.googleapis.com/auth/chat.bot"],
});
const chat = google.chat({ version: "v1", auth });
// Returns spaces the bot has access to
return await chat.spaces.list();
},
})
Google Chat (Service Account Key) uses API keys for authentication. When you connect your Google Chat (Service Account Key) account, Pipedream securely stores the keys so you can easily authenticate to Google Chat (Service Account Key) APIs in both code and no-code steps.