Repository navigation
fix(oauth): move Autodesk sign-in to the v2 authentication API - #15417
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. 🟠 1 high 💬 Inline comments (1)
The change updates only
One notable risk in the new JSON parsing path is called out as an inline finding: an unguarded Reviewed commit: 4ce8e31 |
There was a problem hiding this comment.
This PR migrates the Autodesk OAuth2 adapter to the APS /authentication/v2 authorize and token endpoints, switching from Basic-auth credentials and form-encoded token responses to bearer-token request headers and JSON token responses.
Key findings
- 🟠 Guard the token JSON decode against failure — Autodesk.php:98
| $output = []; | ||
| \parse_str($response, $output); | ||
| $this->tokens = $output; | ||
| $this->tokens = \json_decode($response, true); |
There was a problem hiding this comment.
🟠 bug · high
Guard the token JSON decode against failure
refreshTokens() assigns \json_decode($response, true) directly to the typed protected array $tokens property with no validation (src/Appwrite/Auth/OAuth2/Autodesk.php:98). On an OAuth error response (e.g. invalid_grant, a JSON object without access_token) the error object silently becomes the token array; on a non-JSON body (HTML error page, empty response) json_decode returns null, and assigning null to an array-typed property throws an unrecoverable TypeError. Before this PR, parse_str always produced an array and degraded gracefully, so this is a regression introduced by the v2 migration.
The same unguarded decode exists in getTokens() at src/Appwrite/Auth/OAuth2/Autodesk.php:71 (pre-existing, but should be fixed together). The sibling Google adapter guards both cases via parseTokens() throwing Exception($response, 424).
📋 Prompt for AI Agents
In src/Appwrite/Auth/OAuth2/Autodesk.php, add a private parseTokens(string $response): array method mirroring src/Appwrite/Auth/OAuth2/Google.php lines 117-126: json_decode with assoc=true, throwing new Exception($response, 424) if the result is not an array or lacks a non-empty 'access_token' key. Replace the bare \json_decode($response, true) assignments in getTokens() (line 71) and refreshTokens() (line 98) with calls to this method, so failed or malformed token responses surface as a clean 424 instead of a TypeError (null assigned to the array-typed $tokens property) or a silently accepted OAuth error object.
🔵 Tier A · Mergeable after minor fixes
The Autodesk OAuth adapter now uses the v2 authorization and token endpoints. Token exchange and refresh send client credentials with Basic authentication, and refresh requests use the v2
Fix with agent prompt### Issue 1
src/Appwrite/Auth/OAuth2/Autodesk.php:90
**[minor] Add a mocked test for Autodesk's v2 token flow**
There is no Autodesk-specific test for this changed request contract, while comparable OAuth adapters have mocked request tests. A regression could restore the retired token URL or send the wrong refresh field without being caught; please cover the authorization-code exchange and refresh request/response with a mocked client.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 1
Reviewed |
| 'POST', | ||
| 'https://developer.api.autodesk.com/authentication/v1/refreshtoken', | ||
| [], | ||
| 'https://developer.api.autodesk.com/authentication/v2/token', |
There was a problem hiding this comment.
[minor] Add a mocked test for Autodesk's v2 token flow
There is no Autodesk-specific test for this changed request contract, while comparable OAuth adapters have mocked request tests. A regression could restore the retired token URL or send the wrong refresh field without being caught; please cover the authorization-code exchange and refresh request/response with a mocked client.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Auth/OAuth2/Autodesk.php
Line: 90
Comment:
**[minor] Add a mocked test for Autodesk's v2 token flow**
There is no Autodesk-specific test for this changed request contract, while comparable OAuth adapters have mocked request tests. A regression could restore the retired token URL or send the wrong refresh field without being caught; please cover the authorization-code exchange and refresh request/response with a mocked client.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Stripe, Autodesk and Box sign-in, and the Pinecone, LangChain RAG, Replicate and Redis Cloud templates were held back from the catalog because they didn't work as released. Their fixes are merged (#15414, #15416, #15417, #15421 and appwrite/templates#498), so add their pages: - Autodesk is new. The others come from the held-back drafts, without the workarounds for the template variable names and the hardcoded Redis port. - The template pages say what Any execute access exposes and how to narrow it, like the other template pages. - The pages list Cloud only, because no self-hosted release includes the fixes yet. Each page gets a cover in the catalog style. Etsy sign-in and the GitHub issue bot template still don't work, so they stay out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes #15369.
Autodesk's v1 authentication endpoints return 404.
/authentication/v1/authorize→/authentication/v2/authorize.v1/gettoken/v1/refreshtoken→/authentication/v2/token, with client credentials as basic auth (https://aps.autodesk.com/en/docs/oauth/v2/reference/http/gettoken-POST/).refresh_token(v1 sent it ascode) and parses the JSON response.The user profile call (
userprofile/v1/users/@me) is unchanged. Not tested against a real Autodesk app.