Get google oauth access token and implement google refresh token
Hey everyone! š
I'm working on implementing authentication in my Next.js app using BetterAuth with Google OAuth, and I could use some help with two things:
How can I retrieve the user's access_token after login?
What's the best way to implement token refresh with BetterAuth in a Next.js setup?
If anyone has experience with this or can point me to some solid resources or examples, Iād really appreciate it! š
Thanks in advance! š
6 Replies
How can I retrieve the user's access_token after login?You can query your DB
What's the best way to implement token refresh with BetterAuth in a Next.js setup?I could be wrong but I think we're in the makings for a better api regarding this. @bekacru ?
You can query your DBIs this the only way, if it is alright i can use somekind of caching to reduce db stress
I could be wrong but I think we're in the makings for a better api regarding this.Well currently for this i create a temporary way to refresh the oauth2 access token, let me know if you guys already implement the better way to do this thanks for the response
for the accessToken , it is stored on account Table along with refreshToken.
you can use the internalAdapter for findAccount and get the access token for there . if you could get an access to ctx you can do this way
yeah for the refresh token , you can lets say i used twitter, i can do sth like this .. the url might not correct but you can pass your way of refreshing access token.
for the refresh access token when is the function gonna run,
if you use your authClient for calling to authClient.refreshToken()
aight thanks man