Skip to content

fix(oauth): remove JWT-only manage_app_users scope and space-delimit Box scopes - #15420

Merged
HarshMN2345 merged 4 commits into
appwrite:fix-box-oauth-scopefrom
hardikkaurani:fix-15371-box-oauth-scopes
Nov 9, 2026
Merged

HarshMN2345 merged 4 commits into
appwrite:fix-box-oauth-scopefrom
hardikkaurani:fix-15371-box-oauth-scopes

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #15371.

  1. Remove JWT-only default scope: Box documents manage_app_users as applying only to server-side authenticated (JWT) applications. Standard user authentication OAuth 2.0 apps do not use this scope and will fail authorization. The default scopes are now empty ([]), allowing Box to fall back to the scopes configured on the app in the Box Developer Console.
  2. Space-delimit custom scopes: Box OAuth 2.0 requires space-delimited scopes in the authorize URL query parameter instead of comma-separated ones. Custom scopes are now joined with a space when provided, and omitted when empty.
  3. Clean token exchange parameters: The token endpoint (/oauth2/token) does not take scope for authorization_code grant; removed extraneous comma-separated scope from token request payload.
  4. Update profile endpoint: Point getUser() to Box's official /users/me endpoint (https://api.box.com/2.0/users/me).

Test Plan

  • Added unit tests in tests/unit/Auth/OAuth2/BoxTest.php:
    • testDefaultScopesAreEmptyAndLoginURLOmitsScope: verifies default scopes are empty and no scope param is attached to the authorize URL.
    • testLoginURLWithCustomScopesUsesSpaceDelimiter: verifies custom scopes are space-delimited.
    • testTokenExchangeRequestAndResponse: verifies token exchange payload format and headers.
    • testRefreshTokenRequest: verifies token refresh request.
    • testGetUserProfileQueriesUsersMeEndpoint: verifies user profile request to /users/me and attribute parsing.
  • Ran test suite with PHPUnit 12.5.35:
    • tests/unit/Auth/OAuth2/BoxTest.php: 5 tests, 33 assertions passed.
    • Full suite tests/unit/Auth/OAuth2/: 99 tests, 434 assertions passed.
  • Ran code formatter/linter with Pint:
    • vendor/bin/pint --test --config pint.json src/Appwrite/Auth/OAuth2/Box.php tests/unit/Auth/OAuth2/BoxTest.php: PASS (2 files).

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? (N/A: No API metadata changes)

Copilot AI balanced review requested due to automatic review settings November 9, 2026 08:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi @eldadfux and @HarshMN2345, please review this PR when you have a moment. It resolves #15371 by removing the JWT-only manage_app_users scope from the default scopes, space-delimiting custom scopes on the Box authorize URL when specified, updating the user profile endpoint to /users/me, and cleaning up token exchange parameters. All unit tests (including the new suite in ests/unit/Auth/OAuth2/BoxTest.php) and Pint lint checks pass cleanly.

@appwrite

appwrite Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The Box OAuth2 adapter now defaults to no requested scopes, formats any configured scopes as a space-delimited authorize parameter, and omits scope from token exchange requests. It also queries the Box /users/me profile endpoint, with unit tests covering the updated URLs and request payloads.

Verdict New comments Fixed Still open
💬 Commented 0 0 0

Note

@hardikkaurani does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

📂 Walkthrough · 2
File Change
src/Appwrite/Auth/OAuth2/Box.php Updates Box scope handling, token request parameters, and the current-user endpoint.
tests/unit/Auth/OAuth2/BoxTest.php Adds coverage for Box authorize URLs, token requests, and profile lookup.

Merged main (951efe4); no changes to this PR's code since 47bdc0d · Details · Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@HarshMN2345
HarshMN2345 changed the base branch from main to fix-box-oauth-scope November 9, 2026 08:43
@HarshMN2345
HarshMN2345 merged commit 4a430e4 into appwrite:fix-box-oauth-scope Nov 9, 2026
1 check passed
@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Thanks @HarshMN2345

@HarshMN2345

Copy link
Copy Markdown
Member

Thanks for your contribution! Merged into appwrite/appwrite#15421 · fix(oauth): make Box sign-in…, which also fixes the Box profile request, and thats going to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: Box OAuth2 adapter always requests the JWT-only manage_app_users scope

3 participants