Skip to content

fix(oauth): move Autodesk sign-in to the v2 authentication API - #15417

Merged
HarshMN2345 merged 1 commit into
mainfrom
fix-autodesk-oauth-v2
Nov 9, 2026
Merged

HarshMN2345 merged 1 commit into
mainfrom
fix-autodesk-oauth-v2

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Fixes #15369.

Autodesk's v1 authentication endpoints return 404.

The user profile call (userprofile/v1/users/@me) is unchanged. Not tested against a real Autodesk app.

@luxor-code-review

luxor-code-review Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 1 high

💬 Inline comments (1)


The change updates only src/Appwrite/Auth/OAuth2/Autodesk.php. The adapter now points getAuthorizeURL() and getTokens() at developer.api.autodesk.com/authentication/v2, sends the Authorization: Bearer <access_token> header style used by v2, parses token responses as JSON instead of parse_str, and passes the refresh token as a JSON body field when refreshing. Scopes are passed space-separated through the v2 authorize URL.

Files Change
src/Appwrite/Auth/OAuth2/Autodesk.php Migrates authorize/token endpoints to /authentication/v2, switches to Bearer headers and JSON token parsing, and adds the refresh-token body param for v2.

One notable risk in the new JSON parsing path is called out as an inline finding: an unguarded json_decode assigned to the array-typed $tokens property.

Reviewed commit: 4ce8e31

@luxor-code-review luxor-code-review 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.

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

$output = [];
\parse_str($response, $output);
$this->tokens = $output;
$this->tokens = \json_decode($response, true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 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.

@appwrite

appwrite Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The API migration looks consistent with the stated v2 contract, but its changed token flows need a mocked regression test.

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 refresh_token field and JSON response format.

Verdict New comments Fixed Still open
✅ Approved 1 0 0
Finding Where
🟡 [minor] Add a mocked test for Autodesk's v2 token flow src/Appwrite/Auth/OAuth2/Autodesk.php:90
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
File Change
src/Appwrite/Auth/OAuth2/Autodesk.php Migrates Autodesk authorization, token exchange, and refresh to the v2 OAuth API.

Reviewed 4ce8e31 · 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 A · Looks good to merge. Summary

'POST',
'https://developer.api.autodesk.com/authentication/v1/refreshtoken',
[],
'https://developer.api.autodesk.com/authentication/v2/token',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix-autodesk-oauth-v2 (after).

Metric Before After Change
🚀 Requests/sec 218.14 220.02 ⚪ +0.9%
⏱️ Latency P50 76.91 ms 79.24 ms ⚪ +3%
⏱️ Latency P95 191.39 ms 182.88 ms ⚪ -4.4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 79.24 182.88 13,680 220.02 -8.51
Account 153.2 288.11 720 12.28 -4.09
TablesDB 76.56 141.85 7,440 122.47 +4.23
Storage 72.99 161.84 3,600 60.99 -17.85
Functions 110.72 218.89 1,920 33.13 -26.46

Top API waits (after)

API request Max wait (ms)
account.name.update 406.85
storage.buckets.create 387.92
functions.create 372.88
account.prefs.update 370.19
functions.delete 356.92

@HarshMN2345
HarshMN2345 merged commit 951efe4 into main Nov 9, 2026
36 checks passed
adityaoberai added a commit that referenced this pull request Nov 9, 2026
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]>
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: Autodesk OAuth2 adapter calls retired v1 authentication endpoints

1 participant