MCPcopy Index your code
hub / github.com/simstudioai/sim / getProviderAuthConfig

Function getProviderAuthConfig

apps/sim/lib/oauth/oauth.ts:1065–1425  ·  view source on GitHub ↗

* Get OAuth provider configuration for token refresh

(provider: string)

Source from the content-addressed store, hash-verified

1063 * Get OAuth provider configuration for token refresh
1064 */
1065function getProviderAuthConfig(provider: string): ProviderAuthConfig {
1066 const getCredentials = (clientId: string | undefined, clientSecret: string | undefined) => {
1067 if (!clientId || !clientSecret) {
1068 throw new Error(`Missing client credentials for provider: ${provider}`)
1069 }
1070 return { clientId, clientSecret }
1071 }
1072
1073 switch (provider) {
1074 case 'google': {
1075 const { clientId, clientSecret } = getCredentials(
1076 env.GOOGLE_CLIENT_ID,
1077 env.GOOGLE_CLIENT_SECRET
1078 )
1079 return {
1080 tokenEndpoint: 'https://oauth2.googleapis.com/token',
1081 clientId,
1082 clientSecret,
1083 useBasicAuth: false,
1084 }
1085 }
1086 case 'x': {
1087 const { clientId, clientSecret } = getCredentials(env.X_CLIENT_ID, env.X_CLIENT_SECRET)
1088 return {
1089 tokenEndpoint: 'https://api.x.com/2/oauth2/token',
1090 clientId,
1091 clientSecret,
1092 useBasicAuth: true,
1093 supportsRefreshTokenRotation: true,
1094 }
1095 }
1096 case 'confluence': {
1097 const { clientId, clientSecret } = getCredentials(
1098 env.CONFLUENCE_CLIENT_ID,
1099 env.CONFLUENCE_CLIENT_SECRET
1100 )
1101 return {
1102 tokenEndpoint: 'https://auth.atlassian.com/oauth/token',
1103 clientId,
1104 clientSecret,
1105 useBasicAuth: true,
1106 supportsRefreshTokenRotation: true,
1107 }
1108 }
1109 case 'jira': {
1110 const { clientId, clientSecret } = getCredentials(env.JIRA_CLIENT_ID, env.JIRA_CLIENT_SECRET)
1111 return {
1112 tokenEndpoint: 'https://auth.atlassian.com/oauth/token',
1113 clientId,
1114 clientSecret,
1115 useBasicAuth: true,
1116 supportsRefreshTokenRotation: true,
1117 }
1118 }
1119 case 'calcom': {
1120 const clientId = env.CALCOM_CLIENT_ID
1121 if (!clientId) {
1122 throw new Error('Missing CALCOM_CLIENT_ID')

Callers 1

refreshOAuthTokenFunction · 0.85

Calls 1

getCredentialsFunction · 0.85

Tested by

no test coverage detected