Skip to content

Commit 5b7f875

Browse files
committed
fix(oauth): stop forcing prompt=consent on non-Google providers
The base OAuth provider hardcoded prompt=consent and access_type=offline on every authorize URL. Both are Google-specific: prompt=consent caused GitHub, Microsoft, Discord, GitLab, Apple, and X to re-show their authorization screen on every sign-in, and access_type=offline was silently ignored by every non-Google provider. Move both params into Google's authorizationExtraParams so Google's behavior is unchanged (refresh token still reliably issued via prompt=consent + access_type=offline), and let other providers fall back to standard OAuth behavior: consent only on first authorization, new scopes, or after the user revokes the grant. Update the Spotify e2e snapshot to drop the now-absent params.
1 parent c01c052 commit 5b7f875

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

apps/backend/src/oauth/providers/base.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ export abstract class OAuthBaseProvider {
204204
}),
205205
state: options.state,
206206
response_type: "code",
207-
access_type: "offline",
208-
prompt: "consent",
209207
...this.authorizationExtraParams,
210208
});
211209
}

apps/backend/src/oauth/providers/google.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class GoogleProvider extends OAuthBaseProvider {
2424
baseScope: "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile",
2525
authorizationExtraParams: {
2626
prompt: "consent",
27+
access_type: "offline",
2728
include_granted_scopes: "true",
2829
},
2930
...options,

apps/e2e/tests/backend/endpoints/api/v1/auth/oauth/authorize.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ it("should redirect the user to the OAuth provider with the right arguments even
4444
expect(response.authorizeResponse.status).toBe(307);
4545
const secondLocation = response.authorizeResponse.headers.get("location");
4646
expect(secondLocation).toBeTruthy();
47-
expect(secondLocation).toMatchInlineSnapshot(`"http://localhost:<$NEXT_PUBLIC_STACK_PORT_PREFIX>14/auth?client_id=spotify&scope=openid+offline_access&response_type=code&redirect_uri=%3Cstripped+query+param%3E&code_challenge_method=S256&code_challenge=%3Cstripped+query+param%3E&state=%3Cstripped+query+param%3E&access_type=offline&prompt=consent"`);
47+
expect(secondLocation).toMatchInlineSnapshot(`"http://localhost:<$NEXT_PUBLIC_STACK_PORT_PREFIX>14/auth?client_id=spotify&scope=openid+offline_access&response_type=code&redirect_uri=%3Cstripped+query+param%3E&code_challenge_method=S256&code_challenge=%3Cstripped+query+param%3E&state=%3Cstripped+query+param%3E"`);
4848
expect(response.authorizeResponse.headers.get("set-cookie")).toMatch(/^stack-oauth-inner-[^;]+=[^;]+; Path=\/; Expires=[^;]+; Max-Age=\d+;( Secure;)? HttpOnly$/);
4949
});
5050

@@ -59,7 +59,7 @@ it("should return the OAuth location as JSON when requested by the SDK flow", as
5959
expect(response).toMatchInlineSnapshot(`
6060
NiceResponse {
6161
"status": 200,
62-
"body": { "location": "http://localhost:<$NEXT_PUBLIC_STACK_PORT_PREFIX>14/auth?client_id=spotify&scope=openid+offline_access&response_type=code&redirect_uri=%3Cstripped+query+param%3E&code_challenge_method=S256&code_challenge=%3Cstripped+query+param%3E&state=%3Cstripped+query+param%3E&access_type=offline&prompt=consent" },
62+
"body": { "location": "http://localhost:<$NEXT_PUBLIC_STACK_PORT_PREFIX>14/auth?client_id=spotify&scope=openid+offline_access&response_type=code&redirect_uri=%3Cstripped+query+param%3E&code_challenge_method=S256&code_challenge=%3Cstripped+query+param%3E&state=%3Cstripped+query+param%3E" },
6363
"headers": Headers { <some fields may have been hidden> },
6464
}
6565
`);

0 commit comments

Comments
 (0)