diff --git a/src/app/(oauth)/oauth/authorize/page.tsx b/src/app/(oauth)/oauth/authorize/page.tsx
index 00c54c1..8095572 100644
--- a/src/app/(oauth)/oauth/authorize/page.tsx
+++ b/src/app/(oauth)/oauth/authorize/page.tsx
@@ -6,10 +6,11 @@ import { Authorizing } from "@/components/auth/authorizing";
import { ErrorCard } from "@/components/auth/error-card";
export interface AuthorizeParams {
- oauth: string;
- clientId: string;
- scope: string;
- redirectUri: string;
+ response_type: string;
+ client_id: string;
+ redirect_uri: string;
+ scope?: string;
+ state?: string;
}
export default async function AuthorizePage({
@@ -22,14 +23,33 @@ export default async function AuthorizePage({
redirect("/login");
}
- const client = await getClientByClientId(searchParams.clientId);
+ // 验证必要的参数
+ if (
+ !searchParams.response_type ||
+ !searchParams.client_id ||
+ !searchParams.redirect_uri
+ ) {
+ return (
+
@@ -44,7 +64,7 @@ export default async function AuthorizePage({
@@ -53,13 +73,13 @@ export default async function AuthorizePage({
}
// 检查回调地址是否匹配
- if (client.redirectUri !== searchParams.redirectUri) {
+ if (client.redirectUri !== searchParams.redirect_uri) {
return (
@@ -67,9 +87,25 @@ export default async function AuthorizePage({
);
}
+ // 构建 OAuth 参数
+ const oauthParams = new URLSearchParams();
+ oauthParams.set("response_type", searchParams.response_type);
+ oauthParams.set("client_id", searchParams.client_id);
+ oauthParams.set("redirect_uri", searchParams.redirect_uri);
+ if (searchParams.scope) oauthParams.set("scope", searchParams.scope);
+ if (searchParams.state) oauthParams.set("state", searchParams.state);
+
+ // 转换参数格式
+ const authorizeParams = {
+ oauth: btoa(oauthParams.toString()),
+ clientId: client.id,
+ scope: searchParams.scope || "read_profile",
+ redirectUri: searchParams.redirect_uri,
+ };
+
return (
);
}