diff --git a/apps/web/src/components/organizations/byok/OpenAiChatGptCard.test.ts b/apps/web/src/components/organizations/byok/OpenAiChatGptCard.test.ts index 7e3e6f3524c..816ceabfcc4 100644 --- a/apps/web/src/components/organizations/byok/OpenAiChatGptCard.test.ts +++ b/apps/web/src/components/organizations/byok/OpenAiChatGptCard.test.ts @@ -482,7 +482,7 @@ describe('startOpenAiChatGptConnect', () => { expect(signIn).toHaveBeenCalledWith( 'openai', { callbackUrl: '/byok' }, - { scope: OPENAI_TOKEN_SHARING_SCOPE } + { scope: OPENAI_TOKEN_SHARING_SCOPE, force_reconsent: 'true' } ); expect(createLinkingSession.mock.invocationCallOrder[0]).toBeLessThan( signIn.mock.invocationCallOrder[0] @@ -498,7 +498,7 @@ describe('startOpenAiChatGptConnect', () => { expect(signIn).toHaveBeenCalledWith( 'openai', { callbackUrl: '/organizations/00000000-0000-4000-8000-000000000001/byok' }, - { scope: OPENAI_TOKEN_SHARING_SCOPE } + { scope: OPENAI_TOKEN_SHARING_SCOPE, force_reconsent: 'true' } ); }); diff --git a/apps/web/src/lib/auth/openai/config.test.ts b/apps/web/src/lib/auth/openai/config.test.ts index fa772739f46..aeffc7ed1bf 100644 --- a/apps/web/src/lib/auth/openai/config.test.ts +++ b/apps/web/src/lib/auth/openai/config.test.ts @@ -50,7 +50,7 @@ describe('OpenAI OAuth config', () => { 'email', 'offline_access', 'resource.invoke', - 'chatpass.enable.request', + 'chatgpt.tokens.use.obo', ]); expect(OPENAI_RESOURCE).toBe('https://api.openai.com/v1'); }); @@ -66,7 +66,7 @@ describe('OpenAI OAuth config', () => { ); // A grant that can call the resource and refresh, but that declined the // ChatGPT allowance consent, must stay an identity sign-in: token sharing - // cannot spend the allowance without `chatpass.enable.request`. + // cannot spend the allowance without `chatgpt.tokens.use.obo`. expect( isOpenAiTokenSharingGrant({ scope: 'openid profile email resource.invoke offline_access', diff --git a/apps/web/src/lib/auth/openai/connect.ts b/apps/web/src/lib/auth/openai/connect.ts index e8905ffbd06..8f86a557674 100644 --- a/apps/web/src/lib/auth/openai/connect.ts +++ b/apps/web/src/lib/auth/openai/connect.ts @@ -31,6 +31,6 @@ export async function startOpenAiChatGptConnect( await signIn( 'openai', { callbackUrl: openAiChatGptByokPath(organizationId) }, - { scope: OPENAI_TOKEN_SHARING_SCOPE } + { scope: OPENAI_TOKEN_SHARING_SCOPE, force_reconsent: 'true' } ); } diff --git a/apps/web/src/lib/auth/openai/scopes.ts b/apps/web/src/lib/auth/openai/scopes.ts index c64386980e9..bdfc3cb7f5f 100644 --- a/apps/web/src/lib/auth/openai/scopes.ts +++ b/apps/web/src/lib/auth/openai/scopes.ts @@ -12,7 +12,7 @@ export const OPENAI_IDENTITY_SCOPE = 'openid profile email'; /** Token-sharing scopes, used once a client is approved for delegated access. */ export const OPENAI_TOKEN_SHARING_SCOPE = - 'openid profile email offline_access resource.invoke chatpass.enable.request'; + 'openid profile email offline_access resource.invoke chatgpt.tokens.use.obo'; /** The API resource that token sharing targets. */ export const OPENAI_RESOURCE = 'https://api.openai.com/v1'; @@ -20,7 +20,7 @@ export const OPENAI_RESOURCE = 'https://api.openai.com/v1'; /** * The scopes that make a grant a delegated BYOK credential rather than an * identity-only sign-in. `resource.invoke` is what permits calling the API - * resource on the person's behalf, `chatpass.enable.request` is the consent to + * resource on the person's behalf, `chatgpt.tokens.use.obo` is the consent to * spend the person's ChatGPT allowance, and `offline_access` is what makes the * token renewable without another sign-in. An identity-only sign-in grants * none of them, and a person can decline token sharing while still granting @@ -28,7 +28,7 @@ export const OPENAI_RESOURCE = 'https://api.openai.com/v1'; */ const OPENAI_DELEGATED_GRANT_SCOPES = [ 'resource.invoke', - 'chatpass.enable.request', + 'chatgpt.tokens.use.obo', 'offline_access', ] as const; diff --git a/apps/web/src/lib/user/server-signin-callback.test.ts b/apps/web/src/lib/user/server-signin-callback.test.ts index a98d6eb5da7..8426331a529 100644 --- a/apps/web/src/lib/user/server-signin-callback.test.ts +++ b/apps/web/src/lib/user/server-signin-callback.test.ts @@ -304,7 +304,7 @@ describe('authOptions.callbacks.signIn auto-link wiring', () => { type: 'oauth', access_token: 'access-token', refresh_token: 'refresh-token', - scope: 'openid profile email offline_access resource.invoke chatpass.enable.request', + scope: 'openid profile email offline_access resource.invoke chatgpt.tokens.use.obo', }, profile: { sub: 'openai-sub', email: 'sso-link@example.com' }, } as never); @@ -339,7 +339,7 @@ describe('authOptions.callbacks.signIn auto-link wiring', () => { type: 'oauth', access_token: 'access-token', refresh_token: 'refresh-token', - scope: 'openid profile email offline_access resource.invoke chatpass.enable.request', + scope: 'openid profile email offline_access resource.invoke chatgpt.tokens.use.obo', }, profile, } as never); @@ -392,7 +392,7 @@ describe('authOptions.callbacks.signIn auto-link wiring', () => { type: 'oauth', access_token: 'access-token', refresh_token: 'refresh-token', - scope: 'openid profile email offline_access resource.invoke chatpass.enable.request', + scope: 'openid profile email offline_access resource.invoke chatgpt.tokens.use.obo', }, profile: { sub: 'openai-shared-services-sub', email: 'shared-services@example.com' }, } as never);