In firebase, from their firebase-admin sdk there is a way to get the user.uid from the token received (sent from front)
obviously for security reasons to make sure users has right to access documents etc from server
=> how to do the same with node-appwrite?
Summary
Developers are trying to retrieve the user's ID from a token in a React Native app using Appwrite similar to how it's done in Firebase. To achieve this, they can create a client using the user session and then check if the user is authenticated using account.get(). This process involves setting up the client with the appropriate endpoint and project ID, then retrieving the session cookie from the request. They can use the session in their front-end application to get the user token for the current session.
Gigalink
Rank 1: Thread
Mar 13, 2024, 17:21
and as a matter of fact, from the front react-native-appwrite, how to get the user token for his current session?
Mr. Bakbuki
Mar 13, 2024, 17:22
You could create a client using the user session and check if they're authenticated using account.get()
JavaScript
const sessionClient =newClient()
.setEndpoint('https://cloud.appwrite.io/v1')// Your API Endpoint
.setProject('<YOUR_PROJECT_ID>');// Your project ID
const session = req.cookies.session;// Get the session cookie from the request
if(session){
sessionClient.setSession(session);
}
(this is from the ssr docs)
Gigalink
Rank 1: Thread
Mar 13, 2024, 17:50
this is all frontend though; and only tells me if I'm logged in etc, but I see no token information
the kind of token we usually send inside the headers of a post to backend for security