fartinmartinF
Convex Community11mo ago
12 replies
fartinmartin

Add access token from OAuth provider

I've successfully used the Spotify provider from @auth/core/providers/spotify with covexAuth to create users/sessions in my Convex app.

Now, I'd like to call the Spotify API with the proper access token. I tried using the token generated by Convex Auth's signIn, but this doesn't appear to work—I suppose that makes sense, but it was worth a shot.

Since the Convex Auth docs mention that configs are implemented with Auth.js configs, I took a look at the Auth.js "Extending the session" docs. They expose session and jwt callbacks for the purpose of sending data from a provider to the client. It looks like these callbacks are intentionally left out of the convexAuth implementation, but is there a way to achieve something similar?

https://authjs.dev/guides/extending-the-session

I did notice that Convex Auth's defaultAccount includes account.access_token but am unsure how to access this in my app. Any tips?

https://github.com/get-convex/convex-auth/blob/2f77702b0e42fa705dfe2af623494682e6a21b49/src/server/provider_utils.ts#L118
Was this page helpful?