Back

[SOLVED] User Account Info Retrieval

  • 0
  • Users
  • Flutter
hamed
28 Aug, 2023, 08:22

Hello, I'm having trouble figuring out how to retrieve specific user account information from the admin app. It seems that the 'users.get(id)' function only works on the server side. Am I missing something?

TL;DR
The user is having trouble retrieving specific user account information from the admin app. They are currently using the 'users.get(id)' function, but it seems to only work on the server side. They are seeking guidance on how to receive the server-side response back on the client side. The solution provided is to use Appwrite Functions, and steps are given on how to implement it.
Tessa
28 Aug, 2023, 20:03

hi @hamed , can you elaborate more on your issue - are you using cloud or hosting on your own? what SDK are you using? Are you getting any kind of error? Have you updated the scope with your API key? If you provide as much details of what you've done already it'll help others troubleshoot πŸ™‚

hamed
29 Aug, 2023, 01:33

In the admin app, I've encountered a situation where I need to retrieve specific user preferences. However, I've found that using "account.get" or "account.getPrefs" only provides me with the information of the currently logged-in user. I know that on the server side, I can provide a user ID to these methods to retrieve the desired user's preferences. My question is, how can I receive the server-side response back on the client side?

  • Self hosting
  • Flutter SDK
Drake
29 Aug, 2023, 01:49

You can use the server SDK in an Appwrite function

hamed
29 Aug, 2023, 08:36

I'm not certain how to retrieve a response from the server SDK within an Appwrite function. If you have any insights or information on how to accomplish this, I would greatly appreciate it.

VincentGe
29 Aug, 2023, 15:18

You're not missing anything and it's intended.

Users shouldn't be allowed to get information about other users. This is for privacy reasons.

What you can do is use Appwrite Functions.

  1. Generate an API key with the appropriate scopes:
  2. Create an Appwrite Function using any runtime you're comfortable with.
  3. Pass in the API key as a variable, you can do this in the function's settings.
  4. Include the Appwrite Server SDK as a dependency.
  5. Write your Appwrite Functionm in your case, get user by ID and return results.
  6. Update the execute permissions of your Appwrite function to include only admin users
VincentGe
29 Aug, 2023, 15:19

Then you can execute this function from your Flutter SDK on your Flutter app.

VincentGe
29 Aug, 2023, 15:19

Think of this as building your own endpoints to extend the Appwrite API.

hamed
29 Aug, 2023, 15:58

Thank you for your detailed explanation. I understand the approach, but the part I'm struggling with is how to retrieve the function's response back to the client side after it successfully executes. I truly appreciate your assistance and guidance in this matter.

Drake
29 Aug, 2023, 16:49
hamed
29 Aug, 2023, 17:40

Absolutely, Well I'll definitely consider shifting user preferences to the database instead of keeping them within the account.

D5
30 Aug, 2023, 00:15

I think this should be allowed with permissions and some fields, like other users names. Lots of users need to have a duplicated collection with each user ID and names (like me). I think it doesn't makes sense needing to do that since we have the users API. A solution to prevent duplicate is basically using a function, but is not at all worthy since it will consume a lot of resources for each request, also you're losing the caching layer when using this method

D5
30 Aug, 2023, 00:16

@hamed Can I mark this as solved, or do you need additional assistance?

VincentGe
30 Aug, 2023, 00:44

I think wrapping it in a function is still better. It suggests to users that this is a valid way to use the User API, which it really isn't πŸ˜…

VincentGe
30 Aug, 2023, 00:45

I actually believe the duplicate collection way is also valid

VincentGe
30 Aug, 2023, 00:46

Tell you what @D5 , I think you'll change your mind when you see the new functions πŸ˜‰πŸ˜‰ (after we iron out the bugs after release

D5
30 Aug, 2023, 12:58

Hope yes

D5
30 Aug, 2023, 12:59

[SOLVED] User Account Info Retrieval

VincentGe
31 Aug, 2023, 00:05

😈 Once the release works 🀞 I'm thinking the new functions should be able to solve this problem with user info retrieval.

VincentGe
31 Aug, 2023, 00:05

It's much less effort to maintain a ton of functions

VincentGe
31 Aug, 2023, 00:06

You can have them in the same repo as your app, they support path and query params, and they auto deploy with new push

hamed
31 Aug, 2023, 00:27

I'm really looking forward to giving it a shot <:appwritefire:823999000330895380> , In fact, I've written a lot of code to work around this issue

VincentGe
31 Aug, 2023, 00:33

πŸ˜… I'd like to also appologize for the state of this release at launch

VincentGe
31 Aug, 2023, 00:34

<:appwritepeepo:902865250427215882> Looking forward to what you'll build

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