Skip to content

Commit e0e0f01

Browse files
committed
Merge remote-tracking branch 'origin/staging' into feat/cli-update-notifier
2 parents 94a90ff + 8c2e81c commit e0e0f01

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

apps/sim/lib/auth/connectors/providers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,7 @@ export function buildConnectorProviders(): GenericOAuthConfig[] {
17541754
pkce: true,
17551755
authentication: 'post',
17561756
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/monday`,
1757+
authorizationUrlParams: { force_install_if_needed: 'true' },
17571758
getToken: async ({ code, codeVerifier, redirectURI }) => {
17581759
if (!codeVerifier) {
17591760
throw new Error('Monday OAuth token exchange requires a PKCE verifier')

apps/sim/lib/oauth/oauth.test.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { createMockFetch, resetEnvMock, setEnv } from '@sim/testing'
2-
import { createAuthorizationURL, getOAuth2Tokens } from 'better-auth/oauth2'
2+
import { getOAuth2Tokens } from 'better-auth/oauth2'
3+
import { genericOAuth } from 'better-auth/plugins'
4+
import { getTestInstance } from 'better-auth/test'
35
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
46

57
beforeAll(() => {
@@ -178,26 +180,27 @@ describe('Monday OAuth connector', () => {
178180
pkce: true,
179181
authentication: 'post',
180182
redirectURI: 'http://localhost:3000/api/auth/oauth2/callback/monday',
183+
authorizationUrlParams: { force_install_if_needed: 'true' },
181184
})
182-
const authorizationUrl = await createAuthorizationURL({
183-
id: connector.providerId,
184-
options: {
185-
clientId: connector.clientId,
186-
clientSecret: connector.clientSecret,
187-
redirectURI: connector.redirectURI,
185+
const { auth, signInWithTestUser } = await getTestInstance({
186+
baseURL: 'http://localhost:3000',
187+
plugins: [genericOAuth({ config: [connector] })],
188+
})
189+
const { headers } = await signInWithTestUser()
190+
const { url } = await auth.api.oAuth2LinkAccount({
191+
body: {
192+
providerId: connector.providerId,
193+
callbackURL: 'http://localhost:3000/workspace',
188194
},
189-
authorizationEndpoint: connector.authorizationUrl!,
190-
state: 'state-1',
191-
codeVerifier: 'a'.repeat(128),
192-
scopes: connector.scopes,
193-
redirectURI: connector.redirectURI!,
194-
responseType: connector.responseType,
195+
headers,
195196
})
197+
const authorizationUrl = new URL(url)
196198

197199
expect(authorizationUrl.searchParams.get('redirect_uri')).toBe(
198200
'http://localhost:3000/api/auth/oauth2/callback/monday'
199201
)
200202
expect(authorizationUrl.searchParams.get('scope')).toBe(connector.scopes?.join(' '))
203+
expect(authorizationUrl.searchParams.get('force_install_if_needed')).toBe('true')
201204
expect(authorizationUrl.searchParams.get('code_challenge_method')).toBe('S256')
202205
expect(authorizationUrl.searchParams.get('code_challenge')).toBeTruthy()
203206
})

0 commit comments

Comments
 (0)