Skip to content

Commit c07baf2

Browse files
authored
Merge pull request #5 from kinde-oss/bugfix/build
Add getConfiguration function
2 parents eb07129 + ed67cb0 commit c07baf2

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/lib/KindeSDK.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import {
77
type CCClientOptions,
88
type SessionManager,
99
type PKCEClientOptions,
10-
type ACClientOptions
10+
type ACClientOptions,
11+
Configuration,
12+
type ConfigurationParameters
1113
} from '@kinde-oss/kinde-typescript-sdk';
1214
import {omit} from './utils/index.js';
1315

@@ -37,3 +39,27 @@ export const getHeaders = async () => {
3739
Accept: 'application/json'
3840
};
3941
};
42+
43+
export const getConfiguration = async (configurationOverrides?: ConfigurationParameters) => {
44+
const kindeManagementApi = createKindeServerClient(
45+
GrantType.CLIENT_CREDENTIALS,
46+
omit(kindeConfiguration, [
47+
'logoutRedirectURL',
48+
'loginRedirectURL',
49+
'scope',
50+
'redirectURL'
51+
]) as unknown as CCClientOptions
52+
);
53+
54+
const token = await kindeManagementApi.getToken(sessionStorage as unknown as SessionManager);
55+
56+
const config = new Configuration({
57+
basePath: kindeConfiguration.authDomain,
58+
accessToken: token,
59+
headers: {
60+
Accept: 'application/json'
61+
},
62+
...(configurationOverrides || {})
63+
});
64+
return config;
65+
};

0 commit comments

Comments
 (0)