Skip to content

Commit e041221

Browse files
author
gdauber1
committed
sso_auth
1 parent b624e34 commit e041221

2 files changed

Lines changed: 19 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, serviceToken),
8989
functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
9090
};
9191

‎src/modules/sso.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ 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,
15+
serviceToken?: string
1216
) {
1317
return {
1418
/**
@@ -18,7 +22,19 @@ export function createSsoModule(
1822
*/
1923
async getAccessToken(userid: string) {
2024
const url = `/apps/${appId}/auth/sso/accesstoken/${userid}`;
21-
return axios.get(url);
25+
26+
// Prepare headers with both tokens if available
27+
const headers: Record<string, string> = {};
28+
29+
if (userToken) {
30+
headers['Authorization'] = `Bearer ${userToken}`;
31+
}
32+
33+
if (serviceToken) {
34+
headers['Base44-Service-Authorization'] = `Bearer ${serviceToken}`;
35+
}
36+
37+
return axios.get(url, { headers });
2238
},
2339
};
2440
}

0 commit comments

Comments
 (0)