Back

[Solved] Flutter SDK

  • 0
  • Flutter
سيادة اللواء حناكة
13 Sep, 2023, 05:38

Hi there I am looking forward to add the user id in all requests sent by flutter sdk , but I am not sure how to do it , I know where is the base_request in client_io and client_browser , but I can't find the best way to check if user is signed in and to call his id in the sdk itself to add this for the base request , so if someone can help in ty

TL;DR
The user wants to add the user ID to all requests sent using the Flutter SDK for Appwrite. They are using nginx for logging and need to add the user ID for security purposes. One suggestion is to use a ready function called "addHeader" in "ClientIO" to automatically add the header to all requests. Another suggestion is to use cloud functions and triggers to store the user ID information. The user is not sure how to initialize the client in the SDK and is looking for assistance. There is a suggestion to use `account.get()` to check if the user is logged in and to add the user ID to the requests.
Drake
13 Sep, 2023, 05:45

Why do you need to send the user id when using the Appwrite flutter sdk?

safwan
13 Sep, 2023, 08:04

What's your use-case? Why exactly do you need to send the user id?

You can just use account.get() to see if the user is logged in or not

سيادة اللواء حناكة
13 Sep, 2023, 15:51

I am logging all requests of my server using reverse proxy , so I want to know which user is sending the request for security purposes , I have cookies of user but I Think it's only stored locally

سيادة اللواء حناكة
13 Sep, 2023, 15:51

that's won't work for the sdk as u need to initiate client which isn't possible with easy way from sdk

safwan
13 Sep, 2023, 15:56

I’m confused. Why is initializing a client hard?

safwan
13 Sep, 2023, 15:56

it’s just 3 lines of code

Guille
13 Sep, 2023, 16:15

How are you login your requests?

With cloud functions and triggers you can achieve this and get the user id without any extra step. In the function, you can add the logic to store this info in a collection or in any way you want

سيادة اللواء حناكة
13 Sep, 2023, 18:32

cause I get this error when I try to call the client in the sdk it self , cause i am not sure how it's being manager , I tried " client.setEndpoint('myendpoint').setProject('projectname'); " and got same error

سيادة اللواء حناكة
13 Sep, 2023, 18:34

I am running appwrite behind nginx , which is doing logs for all request , so I want to edit the sdk to send the user id itself , I can't depend on functions ,cause I have full system in behind to manage logs with another apps depends on nginx logs files so can't use appwrite function to manage logs and if I did it won't be that accurate that can nginx does with another special apps

Guille
13 Sep, 2023, 18:54

I see, so one thing could be add a header with the userId on each request, if you get the header is because the user is logged

سيادة اللواء حناكة
13 Sep, 2023, 20:59

Actaully I found a ready function in "ClientIO" called "addHeader"if u called it at the begining of project it will add the header autoamtically to all requests without needng to modify all request and without needing to modify the Sdk it self as I did before .

will leave a picture here if someone serached for it in future

ty for helping for every one <:appwriteheart:782571497393750036>

سيادة اللواء حناكة
13 Sep, 2023, 20:59

[Solved] Flutter SDK

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