Skip to content

fix(oauth): authenticate Stripe token requests with the secret key - #15416

Merged
HarshMN2345 merged 1 commit into
mainfrom
fix-stripe-oauth-secret
Nov 9, 2026
Merged

HarshMN2345 merged 1 commit into
mainfrom
fix-stripe-oauth-secret

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Fixes #15368.

Token exchange and refresh to connect.stripe.com/oauth/token sent no credentials, so Stripe rejected them. Both now send the stored secret key as Authorization: Bearer, per https://docs.stripe.com/connect/oauth-reference.

@luxor-code-review

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

Copy link
Copy Markdown

Review complete. 🟡 1 medium

📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to

🟡 Medium — Stripe token exchange sends secret as Bearer, not client_secret · Stripe.php:72–76 · unchanged line

// src/Appwrite/Auth/OAuth2/Stripe.php
72	                ['Authorization: Bearer ' . $this->appSecret],
73	                \http_build_query([
74	                    'grant_type' => $this->grantType['authorize'],
75	                    'code' => $code
76	                ])

The token and refresh calls authenticate the https://connect.stripe.com/oauth/token request with Authorization: Bearer <appSecret> while the http_build_query body carries only the grant and code (Stripe.php:72, Stripe.php:95). Every other OAuth2 adapter in this repository sends the secret as a client_secret body parameter on its token endpoint, and none use a Bearer header there; Stripe's documented contract for this endpoint is likewise the client_secret form field. If Stripe rejects Bearer auth on the token endpoint, every Stripe OAuth login and token refresh fails, breaking the provider entirely.


This change modifies the Stripe OAuth2 provider's token exchange and refresh flows to send an Authorization: Bearer <appSecret> header alongside the existing form parameters on https://connect.stripe.com/oauth/token, matching the header style already used in getUser().

Files Change
src/Appwrite/Auth/OAuth2/Stripe.php Adds a Bearer authorization header carrying appSecret to both getTokens() and refreshTokens() requests to Stripe's token endpoint.

Note: token exchange on the Connect token endpoint is the one Stripe flow that requires client_id/client_secret form authentication rather than a secret-key Bearer credential, so the header may not substitute for the existing form params.

Reviewed commit: f94538a

@appwrite

appwrite Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The change appears correct, but the new Stripe authentication behavior lacks a regression test.

Stripe OAuth authorization-code exchanges and refresh-token requests now include the configured app secret as a Bearer Authorization header. The existing form-encoded grant payloads remain unchanged.

Verdict New comments Fixed Still open
✅ Approved 1 0 0
Finding Where
🟡 Add a Stripe token-request regression test src/Appwrite/Auth/OAuth2/Stripe.php:72
Fix with agent prompt
### Issue 1
src/Appwrite/Auth/OAuth2/Stripe.php:72
**Add a Stripe token-request regression test**

Could we add a Stripe adapter test that verifies the Authorization header on both exchange and refresh requests? Existing OAuth2 adapter tests cover request contracts, but without this assertion the missing-credentials regression can return unnoticed.

---

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/Stripe.php Adds Bearer authentication to Stripe token exchange and refresh requests.

Reviewed f94538a · 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://connect.stripe.com/oauth/token',
[],
['Authorization: Bearer ' . $this->appSecret],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Add a Stripe token-request regression test

Could we add a Stripe adapter test that verifies the Authorization header on both exchange and refresh requests? Existing OAuth2 adapter tests cover request contracts, but without this assertion the missing-credentials regression can return unnoticed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Auth/OAuth2/Stripe.php
Line: 72

Comment:
**Add a Stripe token-request regression test**

Could we add a Stripe adapter test that verifies the Authorization header on both exchange and refresh requests? Existing OAuth2 adapter tests cover request contracts, but without this assertion the missing-credentials regression can return unnoticed.

---

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

✨ Benchmark results

Comparing main (before) → fix-stripe-oauth-secret (after).

Metric Before After Change
🚀 Requests/sec 203.82 209.79 ⚪ +2.9%
⏱️ Latency P50 85.21 ms 82.63 ms ⚪ -3%
⏱️ Latency P95 201.16 ms 188.49 ms 🟢 -6.3%
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 82.63 188.49 13,281 209.79 -12.67
Account 156.23 281.49 699 11.6 -23.11
TablesDB 79.82 145.9 7,223 117.29 -15.01
Storage 75.81 171.99 3,495 58.45 -11.31
Functions 116.44 217.08 1,864 31.83 -4.31

Top API waits (after)

API request Max wait (ms)
functions.create 471.66
account.name.update 443.34
functions.delete 394.68
account.prefs.update 388.32
functions.variables.update 339.61

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

@HarshMN2345
HarshMN2345 merged commit ac19995 into main Nov 9, 2026
33 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: Stripe OAuth2 sign-in fails because the token exchange never sends the secret key

1 participant