Skip to content

Commit 860bc4c

Browse files
Merge pull request #484 from sethladd/add-chat-spaces-readonly-scope
Add chat.spaces.readonly scope for listing spaces
2 parents 6b21632 + a6988cf commit 860bc4c

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

.github/workflows/ruff.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v6
1717
with:
18-
ref: ${{ github.head_ref || github.ref }}
18+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
19+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
1920
token: ${{ secrets.GITHUB_TOKEN }}
2021
- uses: actions/setup-python@v6
2122
with:
@@ -30,14 +31,14 @@ jobs:
3031
uv run ruff check --fix
3132
uv run ruff format
3233
- name: Commit and push fixes
33-
if: github.event_name == 'pull_request'
34+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
3435
run: |
3536
git diff --quiet && exit 0
3637
git config user.name "github-actions[bot]"
3738
git config user.email "github-actions[bot]@users.noreply.github.com"
3839
git add -A
3940
git commit -m "style: auto-fix ruff lint and format"
40-
git push || echo "::warning::Could not push auto-fixes — fork PRs require 'Allow edits from maintainers' enabled"
41+
git push
4142
- name: Validate
4243
run: |
4344
uv run ruff check

auth/scopes.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
CHAT_READONLY_SCOPE = "https://www.googleapis.com/auth/chat.messages.readonly"
4242
CHAT_WRITE_SCOPE = "https://www.googleapis.com/auth/chat.messages"
4343
CHAT_SPACES_SCOPE = "https://www.googleapis.com/auth/chat.spaces"
44+
CHAT_SPACES_READONLY_SCOPE = "https://www.googleapis.com/auth/chat.spaces.readonly"
4445

4546
# Google Sheets API scopes
4647
SHEETS_READONLY_SCOPE = "https://www.googleapis.com/auth/spreadsheets.readonly"
@@ -98,6 +99,7 @@
9899
TASKS_SCOPE: {TASKS_READONLY_SCOPE},
99100
CONTACTS_SCOPE: {CONTACTS_READONLY_SCOPE},
100101
CHAT_WRITE_SCOPE: {CHAT_READONLY_SCOPE},
102+
CHAT_SPACES_SCOPE: {CHAT_SPACES_READONLY_SCOPE},
101103
FORMS_BODY_SCOPE: {FORMS_BODY_READONLY_SCOPE},
102104
SCRIPT_PROJECTS_SCOPE: {SCRIPT_PROJECTS_READONLY_SCOPE},
103105
SCRIPT_DEPLOYMENTS_SCOPE: {SCRIPT_DEPLOYMENTS_READONLY_SCOPE},
@@ -150,7 +152,12 @@ def has_required_scopes(available_scopes, required_scopes):
150152
GMAIL_SETTINGS_BASIC_SCOPE,
151153
]
152154

153-
CHAT_SCOPES = [CHAT_READONLY_SCOPE, CHAT_WRITE_SCOPE, CHAT_SPACES_SCOPE]
155+
CHAT_SCOPES = [
156+
CHAT_READONLY_SCOPE,
157+
CHAT_WRITE_SCOPE,
158+
CHAT_SPACES_SCOPE,
159+
CHAT_SPACES_READONLY_SCOPE,
160+
]
154161

155162
SHEETS_SCOPES = [SHEETS_READONLY_SCOPE, SHEETS_WRITE_SCOPE, DRIVE_READONLY_SCOPE]
156163

@@ -201,7 +208,7 @@ def has_required_scopes(available_scopes, required_scopes):
201208
"calendar": [CALENDAR_READONLY_SCOPE],
202209
"docs": [DOCS_READONLY_SCOPE, DRIVE_READONLY_SCOPE],
203210
"sheets": [SHEETS_READONLY_SCOPE, DRIVE_READONLY_SCOPE],
204-
"chat": [CHAT_READONLY_SCOPE],
211+
"chat": [CHAT_READONLY_SCOPE, CHAT_SPACES_READONLY_SCOPE],
205212
"forms": [FORMS_BODY_READONLY_SCOPE, FORMS_RESPONSES_READONLY_SCOPE],
206213
"slides": [SLIDES_READONLY_SCOPE],
207214
"tasks": [TASKS_READONLY_SCOPE],

auth/service_decorator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
CHAT_READONLY_SCOPE,
4040
CHAT_WRITE_SCOPE,
4141
CHAT_SPACES_SCOPE,
42+
CHAT_SPACES_READONLY_SCOPE,
4243
FORMS_BODY_SCOPE,
4344
FORMS_BODY_READONLY_SCOPE,
4445
FORMS_RESPONSES_READONLY_SCOPE,
@@ -440,6 +441,7 @@ def _remove_user_email_arg_from_docstring(docstring: str) -> str:
440441
"chat_read": CHAT_READONLY_SCOPE,
441442
"chat_write": CHAT_WRITE_SCOPE,
442443
"chat_spaces": CHAT_SPACES_SCOPE,
444+
"chat_spaces_readonly": CHAT_SPACES_READONLY_SCOPE,
443445
# Forms scopes
444446
"forms": FORMS_BODY_SCOPE,
445447
"forms_read": FORMS_BODY_READONLY_SCOPE,

gchat/chat_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _extract_rich_links(msg: dict) -> List[str]:
9999

100100

101101
@server.tool()
102-
@require_google_service("chat", "chat_read")
102+
@require_google_service("chat", "chat_spaces_readonly")
103103
@handle_http_errors("list_spaces", service_type="chat")
104104
async def list_spaces(
105105
service,

0 commit comments

Comments
 (0)