谷歌登录日志信息打印

This commit is contained in:
qikongjian 2025-09-22 11:50:17 +08:00
parent f019c2bd34
commit 0e46c54971
2 changed files with 27 additions and 4 deletions

View File

@ -16,7 +16,13 @@ export default function OAuthCallback() {
useEffect(() => {
const handleOAuthCallback = async () => {
try {
console.log('OAuth回调页面开始处理...');
console.log('🎯 Google OAuth 回调页面开始处理...');
console.log('📍 回调页面调试信息:');
console.log(' - 完整回调 URL:', window.location.href);
console.log(' - 回调域名:', window.location.hostname);
console.log(' - 回调协议:', window.location.protocol);
console.log(' - 回调路径:', window.location.pathname);
console.log(' - URL 查询参数:', window.location.search);
// 获取URL参数
const params: OAuthCallbackParams = {
@ -26,7 +32,7 @@ export default function OAuthCallback() {
error_description: searchParams.get("error_description") || undefined,
};
console.log('获取到的URL参数:', params);
console.log('📦 获取到的URL参数:', params);
// 检查是否有错误
if (params.error) {

View File

@ -249,7 +249,15 @@ export const signInWithGoogle = async (inviteCode?: string): Promise<void> => {
// 根据环境变量确定redirect_uri
const redirectUri = process.env.NEXT_PUBLIC_GOOGLE_REDIRECT_URI || 'https://www.movieflow.ai/api/auth/google/callback';
console.log('使用的redirect_uri:', redirectUri);
// 详细的调试日志
console.log('🔍 Google OAuth 调试信息:');
console.log(' - 当前域名:', window.location.hostname);
console.log(' - 当前协议:', window.location.protocol);
console.log(' - 当前端口:', window.location.port);
console.log(' - 完整 origin:', window.location.origin);
console.log(' - 环境变量 NEXT_PUBLIC_GOOGLE_REDIRECT_URI:', process.env.NEXT_PUBLIC_GOOGLE_REDIRECT_URI);
console.log(' - 最终使用的 redirect_uri:', redirectUri);
console.log(' - Google Client ID:', GOOGLE_CLIENT_ID);
// 构建Google OAuth2授权URLMedium风格参数
const authParams = new URLSearchParams({
@ -265,7 +273,16 @@ export const signInWithGoogle = async (inviteCode?: string): Promise<void> => {
const authUrl = `https://accounts.google.com/o/oauth2/v2/auth?${authParams.toString()}`;
console.log('跳转到Google授权页面:', authUrl);
console.log('📤 发送给 Google 的完整授权 URL:');
console.log(authUrl);
console.log('📋 URL 参数解析:');
authParams.forEach((value, key) => {
if (key === 'state') {
console.log(` - ${key}: ${JSON.stringify(JSON.parse(value), null, 2)}`);
} else {
console.log(` - ${key}: ${value}`);
}
});
// 保存state到sessionStorage用于验证
sessionStorage.setItem('google_oauth_state', JSON.stringify({