K
Kinde4mo ago
Yvens

add-urls-to-kinde script

After creating a M2M application and setting the client_id and client_secret for my nextjs app. It seems that I can't get the addCallBackUrlToKinde function to work. I also added the scopes authorization related to application_redirect_uris to m2m application: Thank you for your help !
async function addCallbackUrlToKinde (token) {
try {
const response = await fetch(
`${process.env.KINDE_ISSUER_URL}/api/v1/applications/${process.env.KINDE_M2M_CLIENT_ID}/auth_redirect_urls`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
urls: [`https://${process.env.VERCEL_URL}/api/auth/kinde_callback`]
})
}
)

if (!response.ok) {
console.log('response:', response)
throw new Error(
`Failed to add callback URL to Kinde: ${response.statusText}`
)
}

const responseData = await response.json()
console.log(
`SUCCESS: Callback URL added to Kinde: ${process.env.VERCEL_URL}/api/auth/kinde_callback`,
responseData
)
} catch (error) {
console.log('error:', error)
console.error('Failed to add callback URL to Kinde', error)
throw error
}
};
async function addCallbackUrlToKinde (token) {
try {
const response = await fetch(
`${process.env.KINDE_ISSUER_URL}/api/v1/applications/${process.env.KINDE_M2M_CLIENT_ID}/auth_redirect_urls`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
urls: [`https://${process.env.VERCEL_URL}/api/auth/kinde_callback`]
})
}
)

if (!response.ok) {
console.log('response:', response)
throw new Error(
`Failed to add callback URL to Kinde: ${response.statusText}`
)
}

const responseData = await response.json()
console.log(
`SUCCESS: Callback URL added to Kinde: ${process.env.VERCEL_URL}/api/auth/kinde_callback`,
responseData
)
} catch (error) {
console.log('error:', error)
console.error('Failed to add callback URL to Kinde', error)
throw error
}
};
4 Replies
Yvens
YvensOP4mo ago
@Sam - Insider Thank you for the insights. The api keys are the one for the M2M application I created since I can’t authorize the management api for the nextjs app (backend web) application anymore.
Yvens
YvensOP4mo ago
@Sam - Insider : Ok, the full error response I got while using the M2M api credentials is: {"errors": [{"code": "APP_CALLBACKS_NOT_SUPPORTED", "message": "This application does not support callbacks"}]} But When I try to to switch on the kinde management api for the backend web app I get the error "Only M2M applications can access the kinde Management API"
No description
Yvens
YvensOP4mo ago
@Oli - Kinde You can check this here too for more informations
Oli - Kinde
Oli - Kinde4mo ago
Thanks @Yvens. I posted new information in https://discord.com/channels/1070212618549219328/1284806911379640393/1285762291245256757 Are you able to review this information and let me know if you are still experiencing issues?
Want results from more Discord servers?
Add your server