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?
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 π
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
You can use the server SDK in an Appwrite function
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.
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.
- Generate an API key with the appropriate scopes:
- Create an Appwrite Function using any runtime you're comfortable with.
- Pass in the API key as a variable, you can do this in the function's settings.
- Include the Appwrite Server SDK as a dependency.
- Write your Appwrite Functionm in your case, get user by ID and return results.
- Update the execute permissions of your Appwrite function to include only admin users
Then you can execute this function from your Flutter SDK on your Flutter app.
Think of this as building your own endpoints to extend the Appwrite API.
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.
Have you read through this? https://appwrite.io/docs/functions#writingYourOwnFunction
Absolutely, Well I'll definitely consider shifting user preferences to the database instead of keeping them within the account.
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
@hamed Can I mark this as solved, or do you need additional assistance?
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 π
I actually believe the duplicate collection way is also valid
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
Hope yes
[SOLVED] User Account Info Retrieval
π Once the release works π€ I'm thinking the new functions should be able to solve this problem with user info retrieval.
It's much less effort to maintain a ton of functions
You can have them in the same repo as your app, they support path and query params, and they auto deploy with new push
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
π I'd like to also appologize for the state of this release at launch
<:appwritepeepo:902865250427215882> Looking forward to what you'll build
Recommended threads
- The current user is not authorized to pe...
I want to create a document associated with user after log in with OAuth. The user were logged in, but Appwrite said user is unauthorized. User is logged in wi...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...
- Current User is Not authorized
recreating same Thread