Skip to content

Commit c228bb7

Browse files
author
gdauber1
committed
sso_auth
1 parent b624e34 commit c228bb7

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function createClient(config: {
8585
const serviceRoleModules = {
8686
entities: createEntitiesModule(serviceRoleAxiosClient, appId),
8787
integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
88-
sso: createSsoModule(serviceRoleAxiosClient, appId),
88+
sso: createSsoModule(serviceRoleAxiosClient, appId, token),
8989
functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
9090
};
9191

src/modules/sso.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import { AxiosInstance } from "axios";
44
* Creates the SSO module for the Base44 SDK
55
* @param {import('axios').AxiosInstance} axios - Axios instance
66
* @param {string} appId - Application ID
7+
* @param {string} [userToken] - User authentication token
8+
* @param {string} [serviceToken] - Service role authentication token
79
* @returns {Object} SSO module with SSO authentication methods
810
*/
911
export function createSsoModule(
1012
axios: AxiosInstance,
11-
appId: string
13+
appId: string,
14+
userToken?: string
1215
) {
1316
return {
1417
/**
@@ -18,7 +21,16 @@ export function createSsoModule(
1821
*/
1922
async getAccessToken(userid: string) {
2023
const url = `/apps/${appId}/auth/sso/accesstoken/${userid}`;
21-
return axios.get(url);
24+
25+
// Prepare headers with both tokens if available
26+
const headers: Record<string, string> = {};
27+
28+
29+
if (userToken) {
30+
headers['on-behalf-of'] = `Bearer ${userToken}`;
31+
}
32+
33+
return axios.get(url, { headers });
2234
},
2335
};
2436
}

0 commit comments

Comments
 (0)