Back

Integrating Appwrite with FastAPI

  • 0
  • Self Hosted
  • Tools
ngok
4 Jun, 2023, 15:37

Hey awesome community!

I'm trying to build an application where on the server side I have both Appwrite and a FastAPI service. I'd like each request on the FastAPI service to be authenticated through Appwrite (all routes are user-authenticated).

I read this doc: https://appwrite.io/docs/authentication-server, and my questions are:

  1. whats the mechanism to "pass" the JWT token to the FastAPI service? are there any best practices around that? any working snippets (in any language..) would help - where a backend service basically "delegates" the authentication to appwrite.
  2. is this a feasible architecture with Appwrite? my main use-case is to avoid all the gory details of having to implement (yet again) authentication my self. so my assumption was that this should be simple.
  3. are there any alternatives way to achieve this?

if indeed I got through that path I'd be happy to contribute some code snippets to the docs. thx!

TL;DR
User wants to integrate Appwrite with FastAPI for user authentication in their application. They have some questions regarding the mechanism to pass the JWT token to FastAPI and whether this architecture is feasible with Appwrite. They also ask for alternative ways to achieve this.
Drake
4 Jun, 2023, 16:10
  1. Typically, stuff like this is passed in a header
  2. You can do this. In my opinion, it's a little complicated to have an extra back end server.
  3. 1 alternative is similar to how to handle server side rendering: proxy login API calls through your fast API proxy, capture the session cookie, and then store it in session so it can be used later
Drake
4 Jun, 2023, 16:10

What do you need your fast API server for anyways?

ngok
5 Jun, 2023, 07:25

It is going to use a customized DB for CRUD but also manipulating data. there is some "deep" logic there which I believe won't fit into simple cloud functions

ngok
5 Jun, 2023, 08:00

regarding 2 - this is not a common pattern for appwrite? usually its the "only" Backend in applications?

Drake
5 Jun, 2023, 12:47

Yes, the usual scenario is to connect your front end app directly to Appwrite. Any special logic would go into an Appwrite Function

Drake
5 Jun, 2023, 12:47

What's the deep logic that wouldn't fit into an Appwrite Function?

ngok
5 Jun, 2023, 14:31

External API calls to various services, some other specific services (for statistical calculation), maybe fetching some data from batch jobs, etc.

ngok
5 Jun, 2023, 14:31

you think that would fit an appwrite function?

it sounds "all or nothing"

Drake
5 Jun, 2023, 14:58

This sounds like it would work in an appwrite function

Drake
5 Jun, 2023, 14:59

You can go with your route...it's just more work since there's this extra layer you need to manage

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more