Access token from Social Login
I am migrating from Supabase. Everything works well until I tried to find out how can I get the provider token (from Google) after a successful login. I am using more roles on login and then after I want to use the token to authenticate to some Gmail APIs.
I tried to get on
authClient.useSession
and authClient.listAccounts()
. Is there a way?
I am using Hono on backend and React with Vite on frontend.
In Supabase you could get from their session. More info about it and specifically what I want: https://supabase.com/docs/guides/auth/social-login#provider-tokensSocial Login | Supabase Docs
Logging in with social accounts
Solution:Jump to solution
Better Auth doesn't expose the provider tokens on the client. You can make an endpoint and fetch the accounts table.
4 Replies
Solution
Better Auth doesn't expose the provider tokens on the client. You can make an endpoint and fetch the accounts table.
Hmmm, looks good. Does the provider token gets automatically refreshed? @bekacru
If not, do you know how I can manually do it?
currently you'd need to do it manually. But this PR will get merged soon!
https://github.com/better-auth/better-auth/pull/1779
GitHub
feat(api): refresh token endpoint by Kinfe123 · Pull Request #1779 ...
feat: refresh token api
log leak
refetchToken from the accountId
mocking a api endpoint with the function
mocking dir
remvoving extra object wrappers
refresh access token api for fb
refresh access ...
Amazing. Thanks a lot!