Hi all,
Another noob question from me, appreciate all the help I’ve gotten here so far. I’m working on a Redwood web app that has a custom python backend API for a lot of things I need to compute, itegration with other 3rd party services, etc. I’m still using the built-in Prisma/GraphQL stuff for regular DB lookups on the frontend, of course. And I’m using the Clerk integration for user auth.
I’m simply trying to pass along whatever session info I need to the backend so that I can work with the data of a particular user in a secure way. I’m seeing what looks like conflicting info online about what session info is included by default when making calls to my service. I thought I might get JWT stuff “for free” when making calls to my API, but I don’t see any relevant headers coming through when I log stuff in my server.
On the server side (in Flask) I do this in my development environment:
from flask_cors import CORS
cors = CORS(app, supports_credentials=True,
# origins="http://localhost:8910"
resources={r"/*": {"origins": "http://localhost:8910"}})
And on the client I’m making a fetch call like this:
const backendUrl = 'http://0.0.0.0:5000/"
const response = await fetch(backendUrl + 'api/user_lookup', {
method: 'POST',
credentials: 'include',
// headers: {
// Authorization: `Bearer ${auth_token}`,
//},
})
I thought credentials: 'include'
would do something for me, but I don’t see anything come through. I can pass in an auth_token by hand (that I look up via help from useAuth
) as commented-out above, but I don’t think that should be necessary.
I’m sure I’m doing some basic thing wrong or else my mental model is fouled up. Can someone suggest the basic workflow that’s supposed to be used to simply make an API call to my own server and pass along authentication/session data so that I can verify the session/user associated with the call?
(Also to add a little more context: the specific thing I’m trying to do is to implement an API call that lets me perform Plaid integration for the logged-in user. Plaid has a great tutorial for doing all the work necessary to get a Plaid token I can store in my DB that is associated with the user’s Plaid accounts… but in their tutorial they store the retrieved Plaid token in a global variable and that’s it. I want to write the Plaid token to my DB in a row with the user’s ID, for future reference. But to do this safely I need to verify inside my flask API call that I have a valid user session with my Clerk user, and call a Clerk API to validate my session token, etc etc)