Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pi Gmail Extension

English

This is a native Pi extension with no third-party runtime dependencies. It accesses Google OAuth and the Gmail REST API directly and provides the gmail_search, gmail_get, gmail_send, gmail_reply, gmail_modify, and gmail_labels tools.

Install it from npm:

pi install npm:@guquan-2002/pi-gmail

The extension requires your own Google Cloud OAuth 2.0 Desktop app client. Enable the Gmail API in your Google Cloud project, configure the OAuth consent screen, create a Desktop app OAuth client, and download the client_secret_*.json file.

Run this command in Pi:

/gmail-setup /absolute/path/to/client_secret.json

After browser authorization is complete, run /gmail-status to check the status. /gmail-logout deletes the local token but keeps the OAuth client credentials.

The OAuth client credentials and token are stored at:

~/.config/pi-gmail/credentials.json
~/.config/pi-gmail/token.json

The directory permissions are 0700, and the file permissions are 0600. The authorization scopes are gmail.modify and gmail.send. Sending, replying, changing read status, archiving, moving messages to trash, and changing labels all require confirmation before execution. Write operations are rejected when no interactive UI is available.

中文

这是一个不依赖第三方运行时包的原生 Pi 扩展。它直接访问 Google OAuth 和 Gmail REST API,提供 gmail_searchgmail_getgmail_sendgmail_replygmail_modifygmail_labels 工具。

通过 npm 安装:

pi install npm:@guquan-2002/pi-gmail

扩展要求使用你自己的 Google Cloud OAuth 2.0 桌面应用客户端。先在 Google Cloud 项目中启用 Gmail API,配置 OAuth consent screen,并创建 Desktop app 类型的 OAuth client,然后下载 client_secret_*.json

在 Pi 中运行:

/gmail-setup /absolute/path/to/client_secret.json

浏览器授权完成后,可运行 /gmail-status 检查状态。使用 /gmail-logout 会删除本机 token,但保留 OAuth 客户端凭据。

OAuth 客户端凭据和 token 分别保存在:

~/.config/pi-gmail/credentials.json
~/.config/pi-gmail/token.json

目录权限为 0700,文件权限为 0600。授权范围是 gmail.modifygmail.send。发送、回复、标记状态、归档、移入垃圾箱以及标签变更都会在执行前弹出确认;没有交互 UI 时,写操作会被拒绝。

About

Use Gmail in Pi Coding Agent

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages