[PR #6929] [MERGED] fix(cognito): use %20 encoding for scopes instead of + #32573

Closed
opened 2026-04-17 23:21:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6929
Author: @nathannewyen
Created: 12/22/2025
Status: Merged
Merged: 12/23/2025
Merged by: @himself65

Base: canaryHead: fix/cognito-scope-encoding


📝 Commits (1)

  • 9372cc1 fix(cognito): use %20 encoding for scopes instead of +

📊 Changes

1 file changed (+11 additions, -0 deletions)

View changed files

📝 packages/core/src/social-providers/cognito.ts (+11 -0)

📄 Description

Summary

Fixes the Cognito OAuth scope encoding issue where spaces are encoded as + instead of %20.

Problem

AWS Cognito requires scopes to be space-separated with %20 encoding per AWS documentation, but URLSearchParams encodes spaces as + by default.

Solution

After constructing the authorization URL, manually re-encode the scope parameter using encodeURIComponent() which produces %20 for spaces.

Fixes #6840


Summary by cubic

Fixes Cognito OAuth scope encoding to use %20 for spaces instead of +, matching AWS requirements and preventing auth failures with multiple scopes.

  • Bug Fixes
    • Re-encodes the scope query param with encodeURIComponent and appends it to the auth URL so scopes are separated by %20.

Written for commit 9372cc188a. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6929 **Author:** [@nathannewyen](https://github.com/nathannewyen) **Created:** 12/22/2025 **Status:** ✅ Merged **Merged:** 12/23/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/cognito-scope-encoding` --- ### 📝 Commits (1) - [`9372cc1`](https://github.com/better-auth/better-auth/commit/9372cc188a8dfcc61b32724c50570c93c37bec2c) fix(cognito): use %20 encoding for scopes instead of + ### 📊 Changes **1 file changed** (+11 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/social-providers/cognito.ts` (+11 -0) </details> ### 📄 Description ## Summary Fixes the Cognito OAuth scope encoding issue where spaces are encoded as `+` instead of `%20`. ## Problem AWS Cognito requires scopes to be space-separated with `%20` encoding per [AWS documentation](https://docs.aws.amazon.com/cognito/latest/developerguide/authorization-endpoint.html), but `URLSearchParams` encodes spaces as `+` by default. ## Solution After constructing the authorization URL, manually re-encode the scope parameter using `encodeURIComponent()` which produces `%20` for spaces. Fixes #6840 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes Cognito OAuth scope encoding to use %20 for spaces instead of +, matching AWS requirements and preventing auth failures with multiple scopes. - **Bug Fixes** - Re-encodes the scope query param with encodeURIComponent and appends it to the auth URL so scopes are separated by %20. <sup>Written for commit 9372cc188a8dfcc61b32724c50570c93c37bec2c. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 23:21:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#32573