debug: add detailed error logging for Logto M2M token request failures
Logs the URL, resource, app ID prefix, and response body when the token request fails — helps diagnose 400 errors from Logto. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -91,7 +91,17 @@ export class LogtoManagementClient {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(`Logto M2M token request failed: HTTP ${res.status}`);
|
const errorBody = await res.text();
|
||||||
|
console.error(
|
||||||
|
`[Logto M2M] Token request failed: HTTP ${res.status}`,
|
||||||
|
`\n URL: ${tokenUrl}`,
|
||||||
|
`\n Resource: ${config.apiResource}`,
|
||||||
|
`\n App ID: ${config.m2mAppId.slice(0, 8)}...`,
|
||||||
|
`\n Response: ${errorBody}`,
|
||||||
|
);
|
||||||
|
throw new Error(
|
||||||
|
`Logto M2M token request failed: HTTP ${res.status} — ${errorBody}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = (await res.json()) as {
|
const data = (await res.json()) as {
|
||||||
|
|||||||
Reference in New Issue
Block a user