No Error on Google One Tap #659

Closed
opened 2026-03-13 07:59:17 -05:00 by GiteaMirror · 18 comments
Owner

Originally created by @itisyb on GitHub (Feb 11, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Image

After one tap apear I click continue

I don't see any network request after clicking continue as "Yash"

Current vs. Expected behavior

Nothing happens and I don't see any logs.
Is there a way to figure out the logs.

What version of Better Auth are you using?

1.1.15

Provide environment information

- Mac chrome browser

Which area(s) are affected? (Select all that apply)

Other

Auth config (if applicable)

import { createAuthClient } from "better-auth/svelte"
import { oneTapClient } from "better-auth/client/plugins"

export const authClient = createAuthClient({
    baseURL: "http://localhost:5173/api/auth",
    plugins: [
        oneTapClient({
            clientId: "my id"
        })
    ],
})

Additional context

Again I just need to see how can I see the errors

Originally created by @itisyb on GitHub (Feb 11, 2025). ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce <img width="417" alt="Image" src="https://github.com/user-attachments/assets/c373fbb3-8b24-441a-9374-4b60583c646e" /> After one tap apear I click continue I don't see any network request after clicking continue as "Yash" ### Current vs. Expected behavior Nothing happens and I don't see any logs. Is there a way to figure out the logs. ### What version of Better Auth are you using? 1.1.15 ### Provide environment information ```bash - Mac chrome browser ``` ### Which area(s) are affected? (Select all that apply) Other ### Auth config (if applicable) ```typescript import { createAuthClient } from "better-auth/svelte" import { oneTapClient } from "better-auth/client/plugins" export const authClient = createAuthClient({ baseURL: "http://localhost:5173/api/auth", plugins: [ oneTapClient({ clientId: "my id" }) ], }) ``` ### Additional context Again I just need to see how can I see the errors
GiteaMirror added the bug label 2026-03-13 07:59:17 -05:00
Author
Owner

@Bekacru commented on GitHub (Feb 11, 2025):

Open your browser console, there might be an error there. If it's from Better Auth, you should see an error either in your server logs or in the network request tab.

@Bekacru commented on GitHub (Feb 11, 2025): Open your browser console, there might be an error there. If it's from Better Auth, you should see an error either in your server logs or in the network request tab.
Author
Owner

@itisyb commented on GitHub (Feb 11, 2025):

Yes @Bekacru I opened Chrome browse, arc browser
Same for both

@itisyb commented on GitHub (Feb 11, 2025): Yes @Bekacru I opened Chrome browse, arc browser Same for both
Author
Owner
@itisyb commented on GitHub (Feb 11, 2025): https://www.loom.com/share/19ea2ea988af49daa02ba292af895a4b?sid=be6243c0-9a15-400b-97d5-f032da147d00
Author
Owner

@itisyb commented on GitHub (Feb 11, 2025):

Forgot to mention
normal google button flow is working same google id

@itisyb commented on GitHub (Feb 11, 2025): Forgot to mention normal google button flow is working same google id
Author
Owner

@Bekacru commented on GitHub (Feb 12, 2025):

It seems like Better Auth is returning an error. When you click the button, make sure you're on the Network tab so you can see exactly what the error is.

@Bekacru commented on GitHub (Feb 12, 2025): It seems like Better Auth is returning an error. When you click the button, make sure you're on the Network tab so you can see exactly what the error is.
Author
Owner
@itisyb commented on GitHub (Feb 12, 2025): Nope @Bekacru , https://www.loom.com/share/b945824cd2d84a2397df61474273a2f9?sid=3e5798f1-6313-47ec-9a33-6a92254c57ff
Author
Owner

@itisyb commented on GitHub (Feb 12, 2025):

Btw how does google onetap works?

when i used this few months ago in vanilla js

I had to setup up a path/endpoint in my server(similar to normal google)

but in this I didn't do any such thing cause I was using doc am I missing something?

@itisyb commented on GitHub (Feb 12, 2025): Btw how does google onetap works? when i used this few months ago in vanilla js I had to setup up a path/endpoint in my server(similar to normal google) but in this I didn't do any such thing cause I was using doc am I missing something?
Author
Owner

@itisyb commented on GitHub (Feb 14, 2025):

Hi @Bekacru ,
if you could tell me the last part I think I will figure it out sorry to bother you

@itisyb commented on GitHub (Feb 14, 2025): Hi @Bekacru , if you could tell me the last part I think I will figure it out sorry to bother you
Author
Owner

@Bekacru commented on GitHub (Feb 14, 2025):

Hey, Better Auth works in the same way it just set the endpoint of for you. Have you add oneTap plugin in your server?

@Bekacru commented on GitHub (Feb 14, 2025): Hey, Better Auth works in the same way it just set the endpoint of for you. Have you add `oneTap` plugin in your server?
Author
Owner

@itisyb commented on GitHub (Feb 14, 2025):

https://www.better-auth.com/docs/plugins/one-tap

I followed this so added in auth.ts and auth-client.ts

@itisyb commented on GitHub (Feb 14, 2025): https://www.better-auth.com/docs/plugins/one-tap I followed this so added in auth.ts and auth-client.ts
Author
Owner

@Bekacru commented on GitHub (Feb 14, 2025):

Yeah then it should work in general. The issue could be related to your browser. Maybe check the demo and see if it works or not. You can get the live demo on https://demo.better-auth.com/

@Bekacru commented on GitHub (Feb 14, 2025): Yeah then it should work in general. The issue could be related to your browser. Maybe check the demo and see if it works or not. You can get the live demo on https://demo.better-auth.com/
Author
Owner

@itisyb commented on GitHub (Feb 14, 2025):

So I tried demo
and there's a callback in my network tab that I don't have so
@Bekacru.
I am using sveltkit if that helps

@itisyb commented on GitHub (Feb 14, 2025): So I tried demo and there's a callback in my network tab that I don't have so @Bekacru. I am using sveltkit if that helps
Author
Owner

@itisyb commented on GitHub (Feb 14, 2025):

Can we use it in localhost
I read some post localhost could be an issue

@itisyb commented on GitHub (Feb 14, 2025): Can we use it in localhost I read some post localhost could be an issue
Author
Owner

@mattbdc commented on GitHub (Feb 15, 2025):

I get 404 following the guide for svelte kit. even though hooks.server.ts is called, /api/auth/one-tap/callback returns a 404. not sure if there something missing from the guide.

@mattbdc commented on GitHub (Feb 15, 2025): I get 404 following the guide for svelte kit. even though hooks.server.ts is called, /api/auth/one-tap/callback returns a 404. not sure if there something missing from the guide.
Author
Owner

@mattbdc commented on GitHub (Feb 15, 2025):

Ah one needs to enable Google as social provider for the callback to route to register. This isn't in the docs, could be confusing for those relying exclusively on OneTap.

@mattbdc commented on GitHub (Feb 15, 2025): Ah one needs to enable Google as social provider for the callback to route to register. This isn't in the docs, could be confusing for those relying exclusively on OneTap.
Author
Owner

@mattbdc commented on GitHub (Feb 15, 2025):

Respectfully, I wouldn't recommend using this plugin, it should be labelled a proof of concept imo, if you've been through the battlefield with onetap you'll notice the omissions, there are issues on both the client and server side.

The client side one needs to handle prompt dismissals and exponential backoff associated with it (otherwise you just get a no-op on oneTap() after a dismissal) - any non-trivial implementation will be passing a callback to prompt to consider the "moment" [1] and respond with alternatives. This implementation presume prompt is 0 arged and no way to thread through a notification callback (for example to render a google signin button after a dimissal to restart the process).

On the server side, it's going to Google to validate the token which is totally unnecessary, certainly an auth framework should be able to verify a signed token. Google recommends using tokeninfo endpoint for development and debugging only [2]

[1] https://developers.google.com/identity/gsi/web/reference/js-reference#google.accounts.id.prompt
[2] https://developers.google.com/identity/sign-in/web/backend-auth

I'm not sure if we'll be adopting BetterAuth yet, but if we do I'll be happy to contribute changes to make it usable.

@mattbdc commented on GitHub (Feb 15, 2025): Respectfully, I wouldn't recommend using this plugin, it should be labelled a proof of concept imo, if you've been through the battlefield with onetap you'll notice the omissions, **there are issues on both the client and server side**. The client side one needs to handle prompt dismissals and exponential backoff associated with it (otherwise you just get a no-op on oneTap() after a dismissal) - any non-trivial implementation will be passing a callback to prompt to consider the "moment" [1] and respond with alternatives. This implementation presume prompt is 0 arged and no way to thread through a notification callback (for example to render a google signin button after a dimissal to restart the process). On the server side, it's going to Google to validate the token which is totally unnecessary, certainly an auth framework should be able to verify a signed token. Google recommends using tokeninfo endpoint for development and debugging only [2] [1] https://developers.google.com/identity/gsi/web/reference/js-reference#google.accounts.id.prompt [2] https://developers.google.com/identity/sign-in/web/backend-auth I'm not sure if we'll be adopting BetterAuth yet, but if we do I'll be happy to contribute changes to make it usable.
Author
Owner

@itisyb commented on GitHub (Feb 15, 2025):

yaa I am still struggling

I am also going to put my code here

//auth-client.ts
import { createAuthClient } from "better-auth/svelte"
import { oneTapClient } from "better-auth/client/plugins"

export const authClient = createAuthClient({
baseURL: "http://localhost:5173/api/auth",
plugins: [
oneTapClient({
clientId: "myclient id which is same as google and google button is working"
})
],
})

//auth +page.svelte
async function init() {
console.log('Init function called');
if (browser) {
console.log('Browser check passed');
try {
console.log('Attempting One Tap initialization...');

			const response = await authClient.oneTap({
				callbackURL: '/api/auth/sign-in/social', //tried different things here none working
				cancelOnTapOutside: true, 
				context: 'signin',  //tried different things here none working
				autoSelect: true,
				fetchOptions: {
					onSuccess: (data) => {
						console.log('One Tap success callback:', data);
					},
					onError: (error) => {
						console.error('One Tap error callback:', error);
					}
				}
			});

			console.log('One Tap initialization response:', response);
		} catch (error) {
			console.error('One Tap initialization error:', error);
		}
	}
}

in auth.ts
import { betterAuth } from 'better-auth';
import { db } from '$lib/server/db';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import { user, session, account, verification } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
import { nanoid } from 'nanoid';
import { oneTap } from "better-auth/plugins";

// Environment variables
import {
BETTER_AUTH_SECRET,
BETTER_AUTH_URL,
GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET,
//GOOGLE_REDIRECT_URI
} from '$env/static/private';

// Initialize better-auth
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: 'pg',
schema: {
user,
account,
session,
verification,
organization,
organizationMembers
}
}),
advanced: {
cookiePrefix: 'abc'
},
emailAndPassword: {
enabled: true
},
secret: BETTER_AUTH_SECRET,
baseUrl: BETTER_AUTH_URL,
socialProviders: {
google: {
clientId: GOOGLE_CLIENT_ID,
clientSecret: GOOGLE_CLIENT_SECRET,
redirectUri: ${BETTER_AUTH_URL}/api/auth/callback/google
}
},
plugins: [
oneTap(),
]

})

you are my only chance @Bekacru
I love the library @mattbdc but I think documentation is missing that's it.

@itisyb commented on GitHub (Feb 15, 2025): yaa I am still struggling I am also going to put my code here //auth-client.ts import { createAuthClient } from "better-auth/svelte" import { oneTapClient } from "better-auth/client/plugins" export const authClient = createAuthClient({ baseURL: "http://localhost:5173/api/auth", plugins: [ oneTapClient({ clientId: "myclient id which is same as google and google button is working" }) ], }) //auth +page.svelte async function init() { console.log('Init function called'); if (browser) { console.log('Browser check passed'); try { console.log('Attempting One Tap initialization...'); const response = await authClient.oneTap({ callbackURL: '/api/auth/sign-in/social', //tried different things here none working cancelOnTapOutside: true, context: 'signin', //tried different things here none working autoSelect: true, fetchOptions: { onSuccess: (data) => { console.log('One Tap success callback:', data); }, onError: (error) => { console.error('One Tap error callback:', error); } } }); console.log('One Tap initialization response:', response); } catch (error) { console.error('One Tap initialization error:', error); } } } in auth.ts import { betterAuth } from 'better-auth'; import { db } from '$lib/server/db'; import { drizzleAdapter } from 'better-auth/adapters/drizzle'; import { user, session, account, verification } from '$lib/server/db/schema'; import { eq } from 'drizzle-orm'; import { nanoid } from 'nanoid'; import { oneTap } from "better-auth/plugins"; // Environment variables import { BETTER_AUTH_SECRET, BETTER_AUTH_URL, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, //GOOGLE_REDIRECT_URI } from '$env/static/private'; // Initialize better-auth export const auth = betterAuth({ database: drizzleAdapter(db, { provider: 'pg', schema: { user, account, session, verification, organization, organizationMembers } }), advanced: { cookiePrefix: 'abc' }, emailAndPassword: { enabled: true }, secret: BETTER_AUTH_SECRET, baseUrl: BETTER_AUTH_URL, socialProviders: { google: { clientId: GOOGLE_CLIENT_ID, clientSecret: GOOGLE_CLIENT_SECRET, redirectUri: `${BETTER_AUTH_URL}/api/auth/callback/google` } }, plugins: [ oneTap(), ] }) you are my only chance @Bekacru I love the library @mattbdc but I think documentation is missing that's it.
Author
Owner

@itisyb commented on GitHub (Feb 22, 2025):

If anyone looking for solution
https://github.com/better-auth/better-auth/pull/1452#issuecomment-2674124941

@itisyb commented on GitHub (Feb 22, 2025): If anyone looking for solution https://github.com/better-auth/better-auth/pull/1452#issuecomment-2674124941
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#659