Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function createClient(config: {
const serviceRoleModules = {
entities: createEntitiesModule(serviceRoleAxiosClient, appId),
integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
sso: createSsoModule(serviceRoleAxiosClient, appId),
sso: createSsoModule(serviceRoleAxiosClient, appId, token),
functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
};

Expand Down
16 changes: 14 additions & 2 deletions src/modules/sso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import { AxiosInstance } from "axios";
* Creates the SSO module for the Base44 SDK
* @param {import('axios').AxiosInstance} axios - Axios instance
* @param {string} appId - Application ID
* @param {string} [userToken] - User authentication token
* @param {string} [serviceToken] - Service role authentication token
* @returns {Object} SSO module with SSO authentication methods
*/
export function createSsoModule(
axios: AxiosInstance,
appId: string
appId: string,
userToken?: string
) {
return {
/**
Expand All @@ -18,7 +21,16 @@ export function createSsoModule(
*/
async getAccessToken(userid: string) {
const url = `/apps/${appId}/auth/sso/accesstoken/${userid}`;
return axios.get(url);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Prepare headers with both tokens if available
const headers: Record<string, string> = {};
if (userToken) {
headers['Base44-On-Behalf-Of'] = `Bearer ${userToken}`;
}
return axios.get(url, { headers });

the concept

// Prepare headers with both tokens if available
const headers: Record<string, string> = {};


if (userToken) {
headers['on-behalf-of'] = `Bearer ${userToken}`;
}

return axios.get(url, { headers });
},
};
}