Skip to content

Commit

Permalink
community[minor]: added support for subject in gmail tools auth with …
Browse files Browse the repository at this point in the history
…service accounts (#5839)

* fix: added support for subject in gmail tools auth with service accounts

* Update libs/langchain-community/src/tools/gmail/base.ts

---------

Co-authored-by: Brace Sproul <braceasproul@gmail.com>
  • Loading branch information
ahrakos and bracesproul committed Jun 21, 2024
1 parent 3ea0f3a commit 4c93201
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions libs/langchain-community/src/tools/gmail/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface GmailBaseToolParams {
clientEmail?: string;
privateKey?: string;
keyfile?: string;
subject?: string;
};
scopes?: string[];
}
Expand All @@ -25,6 +26,9 @@ export abstract class GmailBaseTool extends StructuredTool {
keyfile: z
.string()
.default(getEnvironmentVariable("GMAIL_KEYFILE") ?? ""),
subject: z
.string()
.default(getEnvironmentVariable("GMAIL_SUBJECT") ?? ""),
})
.refine(
(credentials) =>
Expand Down Expand Up @@ -58,17 +62,19 @@ export abstract class GmailBaseTool extends StructuredTool {
scopes,
credentials.clientEmail,
credentials.privateKey,
credentials.keyfile
credentials.keyfile,
credentials.subject
);
}

private getGmail(
scopes: string[],
email: string,
key?: string,
keyfile?: string
keyfile?: string,
subject?: string
) {
const auth = new google.auth.JWT(email, keyfile, key, scopes);
const auth = new google.auth.JWT(email, keyfile, key, scopes, subject);

return google.gmail({ version: "v1", auth });
}
Expand Down

0 comments on commit 4c93201

Please sign in to comment.