fix(auth): map People service to contacts/directory scope prefixes#414
fix(auth): map People service to contacts/directory scope prefixes#414anshul-garg27 wants to merge 1 commit intogoogleworkspace:mainfrom
Conversation
The People API exposes scopes like `contacts`, `contacts.readonly`, and `directory.readonly`, none of which start with `people`. When users ran `gws auth login -s people`, zero scopes matched because `map_service_to_scope_prefix` returned `"people"` verbatim. Change `map_service_to_scope_prefix` to `map_service_to_scope_prefixes` returning a Vec to support services that map to multiple scope prefixes. Add the `people` → `["contacts", "directory"]` mapping. Chat scopes (chat.spaces, chat.messages) already matched correctly since they share the `chat` prefix, but this is now verified by tests. Closes googleworkspace#310 Closes googleworkspace#316
🦋 Changeset detectedLatest commit: 26a4267 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical authentication issue for the People API within the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request effectively addresses the issue where the people service was not correctly mapping to its associated OAuth scope prefixes. The refactoring of map_service_to_scope_prefix to map_service_to_scope_prefixes to return a Vec<&str> is a sound approach to handle services that map to multiple prefixes. The changes are consistently applied in scope_matches_service and find_unmatched_services, and the addition of new test cases for people and chat services provides good coverage for the updated logic. The solution aligns well with the problem statement and improves the robustness of scope matching.
Summary
peopleservice tocontactsanddirectoryscope prefixes sogws auth login -s peopleincludes the required OAuth scopesmap_service_to_scope_prefix→map_service_to_scope_prefixesto support services that map to multiple scope prefixesProblem
The People API exposes scopes like
contacts,contacts.readonly,contacts.other.readonly, anddirectory.readonly— none of which start withpeople. When users rangws auth login -s people, zero scopes matched because the scope prefix mapper returned"people"verbatim, resulting in403 Request had insufficient authentication scopeserrors.Solution
people"people"(no match)["contacts", "directory"]sheets"spreadsheets"["spreadsheets"]slides"presentations"["presentations"]docs"documents"["documents"]chat"chat"(already worked)["chat"](verified by tests)Test plan
peopleservice matchescontacts,contacts.readonly,contacts.other.readonly,directory.readonlychatservice matcheschat.spaces,chat.messagesfind_unmatched_servicesto use the new multi-prefix functionCloses #310
Closes #316