Skip to content

Commit 2b905f2

Browse files
committed
coming new changes
1 parent 2fd5268 commit 2b905f2

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

app/oauth/authorize/page.tsx

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ export default async function AuthorizePage({
2121
const code_challenge_method = params.code_challenge_method as string | undefined;
2222
const resource = params.resource as string | undefined;
2323

24+
// Enhanced logging for debugging
25+
console.log('[OAuth Authorize] Request params:', {
26+
clientId,
27+
redirectUri,
28+
responseType,
29+
state,
30+
code_challenge: code_challenge ? 'present' : 'missing',
31+
code_challenge_method,
32+
resource
33+
});
34+
2435
if (!session || !session.user || !session.user.id) {
2536
const headersList = await headers();
2637
const host = headersList.get('host');
@@ -42,6 +53,12 @@ export default async function AuthorizePage({
4253
}
4354

4455
if (!clientId || !redirectUri || responseType !== 'code') {
56+
console.log('[OAuth Authorize] Invalid request parameters:', {
57+
clientId: !!clientId,
58+
redirectUri: !!redirectUri,
59+
responseType
60+
});
61+
4562
return (
4663
<main className="flex items-center justify-center h-screen">
4764
<div className="bg-white p-8 rounded-lg shadow-md max-w-sm w-full text-center">
@@ -59,12 +76,43 @@ export default async function AuthorizePage({
5976
where: { clientId },
6077
});
6178

62-
if (!client || !client.redirectUris.includes(redirectUri)) {
79+
// Enhanced error logging
80+
if (!client) {
81+
console.log('[OAuth Authorize] Client not found:', clientId);
6382
return (
6483
<main className="flex items-center justify-center h-screen">
6584
<div className="bg-white p-8 rounded-lg shadow-md max-w-sm w-full text-center">
6685
<h1 className="text-2xl font-bold mb-4">Error</h1>
67-
<p>Invalid client or redirect URI.</p>
86+
<p>Client not found.</p>
87+
<p className="text-xs text-gray-500 mt-4">
88+
Client ID: {clientId}
89+
</p>
90+
<p className="text-xs text-gray-500 mt-2">
91+
Please ensure the client is registered via Dynamic Client Registration.
92+
</p>
93+
</div>
94+
</main>
95+
);
96+
}
97+
98+
if (!client.redirectUris.includes(redirectUri)) {
99+
console.log('[OAuth Authorize] Redirect URI mismatch:', {
100+
clientId,
101+
requestedUri: redirectUri,
102+
registeredUris: client.redirectUris
103+
});
104+
105+
return (
106+
<main className="flex items-center justify-center h-screen">
107+
<div className="bg-white p-8 rounded-lg shadow-md max-w-sm w-full text-center">
108+
<h1 className="text-2xl font-bold mb-4">Error</h1>
109+
<p>Invalid redirect URI.</p>
110+
<p className="text-xs text-gray-500 mt-4">
111+
Requested: {redirectUri}
112+
</p>
113+
<p className="text-xs text-gray-500 mt-2">
114+
Registered URIs: {client.redirectUris.join(', ')}
115+
</p>
68116
</div>
69117
</main>
70118
);

0 commit comments

Comments
 (0)