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-tokens
Social Login | Supabase Docs
Logging in with social accounts
Solution:
Better Auth doesn't expose the provider tokens on the client. You can make an endpoint and fetch the accounts table.
Jump to solution
4 Replies
Solution
bekacru
bekacru2mo ago
Better Auth doesn't expose the provider tokens on the client. You can make an endpoint and fetch the accounts table.
Patrick Lima
Patrick LimaOP2mo ago
Hmmm, looks good. Does the provider token gets automatically refreshed? @bekacru If not, do you know how I can manually do it?
bekacru
bekacru2mo ago
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 ...
Patrick Lima
Patrick LimaOP2mo ago
Amazing. Thanks a lot!

Did you find this page helpful?