how to auth.api.createOIDCProvider without user session
i want to create oauthApps at runtime. but calling createOIDCProvider requires a user session?
await auth.api.createOIDCProvider({
body: {
domain: 'https://github.com',
providerId: 'github',
issuer: 'https://github.com',
authorizationEndpoint: 'https://github.com/login/oauth/authorize',
tokenEndpoint: 'https://github.com/login/oauth/access_token',
userInfoEndpoint: 'https://api.github.com/user',
scopes: ['user:email', 'read:user', 'read:org'],
clientId: '',
clientSecret: '',
},
});
await auth.api.createOIDCProvider({
body: {
domain: 'https://github.com',
providerId: 'github',
issuer: 'https://github.com',
authorizationEndpoint: 'https://github.com/login/oauth/authorize',
tokenEndpoint: 'https://github.com/login/oauth/access_token',
userInfoEndpoint: 'https://api.github.com/user',
scopes: ['user:email', 'read:user', 'read:org'],
clientId: '',
clientSecret: '',
},
});
1 Reply
guess u want us to do this
await db
.insert(ssoProvider)
.values({
id: 'github',
issuer: 'https://github.com',
providerId: 'github',
domain: 'https://github.com',
oidcConfig: JSON.stringify({
issuer: 'https://github.com',
authorizationEndpoint: 'https://github.com/login/oauth/authorize',
tokenEndpoint: 'https://github.com/login/oauth/access_token',
userInfoEndpoint: 'https://api.github.com/user',
scopes: [
'user:email',
'read:user',
'read:org',
'openid',
'offline_access',
],
clientId: '',
clientSecret: '',
}),
})
.onConflictDoNothing({ target: ssoProvider.id });
await db
.insert(ssoProvider)
.values({
id: 'github',
issuer: 'https://github.com',
providerId: 'github',
domain: 'https://github.com',
oidcConfig: JSON.stringify({
issuer: 'https://github.com',
authorizationEndpoint: 'https://github.com/login/oauth/authorize',
tokenEndpoint: 'https://github.com/login/oauth/access_token',
userInfoEndpoint: 'https://api.github.com/user',
scopes: [
'user:email',
'read:user',
'read:org',
'openid',
'offline_access',
],
clientId: '',
clientSecret: '',
}),
})
.onConflictDoNothing({ target: ssoProvider.id });