@@ -21,24 +21,19 @@ export default function GoogleOneTapInitializer({
2121 debugLogger,
2222 siteConfig,
2323} : GoogleOneTapInitializerProps ) : ReactNode {
24- const { baseUrl : apiBaseUrl , logtoAdminConsoleUrl } = useApiBaseUrl ( siteConfig ) ;
25-
26- const verifyGoogleOneTap = useGoogleOneTapVerify ( apiBaseUrl , debugLogger ) ;
24+ const { logtoAdminConsoleUrl } = useApiBaseUrl ( siteConfig ) ;
2725
2826 // Function to manually build Logto sign-in URL
2927 const buildSignInUrl = useCallback (
30- ( { oneTimeToken , email , isNewUser } : GoogleOneTapVerifyResponse ) => {
28+ ( { credential } : GoogleOneTapVerifyResponse ) => {
3129 try {
3230 if ( ! logtoAdminConsoleUrl ) {
3331 throw new Error ( 'Logto admin console URL is not set' ) ;
3432 }
3533
36- const signInUrl = new URL ( appendPath ( new URL ( logtoAdminConsoleUrl ) , 'one-time-token ' ) ) ;
34+ const signInUrl = new URL ( appendPath ( new URL ( logtoAdminConsoleUrl ) , 'google- one-tap ' ) ) ;
3735
38- // Add one-time token parameters
39- signInUrl . searchParams . set ( 'one_time_token' , oneTimeToken ) ;
40- signInUrl . searchParams . set ( 'email' , email ) ;
41- signInUrl . searchParams . set ( 'is_new_user' , isNewUser ? 'true' : 'false' ) ;
36+ signInUrl . searchParams . set ( 'google_one_tap_credential' , credential ) ;
4237
4338 return signInUrl . toString ( ) ;
4439 } catch ( error ) {
@@ -53,28 +48,22 @@ export default function GoogleOneTapInitializer({
5348 async ( response : GoogleOneTapCredentialResponse ) => {
5449 debugLogger . log ( 'handleCredentialResponse received response:' , response ) ;
5550
56- const verifyData = await verifyGoogleOneTap ( response ) ;
57-
58- if ( verifyData ) {
59- debugLogger . log ( 'Verification completed:' , verifyData ) ;
60-
61- try {
62- // Build Logto sign-in URL with one-time token
63- const signInUrl = buildSignInUrl ( verifyData ) ;
64-
65- if ( signInUrl ) {
66- // Directly navigate to sign-in URL in current window
67- window . location . href = signInUrl ;
68- debugLogger . log ( 'Redirecting to Logto sign-in URL' , signInUrl ) ;
69- } else {
70- debugLogger . error ( 'Failed to build sign-in URL' ) ;
71- }
72- } catch ( error ) {
73- debugLogger . error ( 'Failed to open sign-in URL:' , error ) ;
51+ try {
52+ // Build Logto sign-in URL with one-time token
53+ const signInUrl = buildSignInUrl ( response ) ;
54+
55+ if ( signInUrl ) {
56+ // Directly navigate to sign-in URL in current window
57+ window . location . href = signInUrl ;
58+ debugLogger . log ( 'Redirecting to Logto sign-in URL' , signInUrl ) ;
59+ } else {
60+ debugLogger . error ( 'Failed to build sign-in URL' ) ;
7461 }
62+ } catch ( error ) {
63+ debugLogger . error ( 'Failed to open sign-in URL:' , error ) ;
7564 }
7665 } ,
77- [ verifyGoogleOneTap , debugLogger , buildSignInUrl ]
66+ [ debugLogger , buildSignInUrl ]
7867 ) ;
7968
8069 useEffect ( ( ) => {
0 commit comments