React + Fastapi authentication

My company has an internal tool built. It has a react frontend and a fastapi backend with REST Apis that the react frontend will use. I want to implement company’s Okta SSO authentication in the react app so that any internal employee can login and get a jwt token. After login, using the jwt token, the frontend should be able to use fastapi Rest endpoints.

How can I implement this in the frontend and backend?

Your React front-end would handle the OIDC portion (requesting and receiving JWTs for logged in users) and could then send the JWT Access Token as a Bearer token your your REST API. You can check out our sample apps to see how this would work as our front-end samples (including the React one I list below) and our back-end/middleware samples are designed to work this way:

  • React sample app
  • Back-end aample apps (this is a stand-in for your own REST API, but you can see how our samples handle authorization: Node, Java, .NET Core