console.log("current", currentUser)
if (currentUser) {
const query = new Moralis.Query("Session");
console.log("weqw", await query.find());
} else {
// show the signup or login page
const user = await Moralis.User.logIn("karthi12", "karthi12").then(async (user) => {
console.log("dfds", user, user.id)
const query1 = new Moralis.Query("Session")
let c = await query1.equalTo("user", user.id
)
console.log(c)
await c.find().then((asa) => {
console.log("ad", asa)
})
});
}```
it looks ok, it will only work for current user if you don’t user master key
How to fetch the master key then ?
https://docs.moralis.io/moralis-server/cloud-code/cloud-functions#using-the-master-key-in-cloud-code
ParseQuery {
className: 'Session',
_where: { user: 'cyrGBpn0PFnLyYAuh5JNFhjR' },
_include: [],
_exclude: [],
_select: undefined,
_limit: -1,
_skip: 0,
_count: false,
_order: undefined,
_readPreference: null,
_includeReadPreference: null,
_subqueryReadPreference: null,
_queriesLocalDatastore: false,
_localDatastorePinName: null,
_extraOptions: {},
_hint: undefined,
_explain: undefined,
_xhrRequest: { task: null, onchange: [Function: onchange] }
}
This is the reponse I am getting
Not able to get the session token
you try that in front end?
you can use master key in backend or in a cloud function
I need to get the user in backend
I tried like authenticating user in backend and sending session token to frontend
Is there any other way??
usually you do it the other way, you authenticate the user in front end and you read the session in backend
How to take session token from wallet address in backend ?
I will send wallet address to backend from frontend
you send it in cookies from front end, and in front end you already have the session token
Hi I will explain what I am trying to do. There is some misunderstanding in that question I think
I am planning to build mobile app which will be used to connect to wallet, checking balance, NFTs and transfer of tokens and NFTs. I am doing it in unity
As of now with unity package there is only get methods are there
There are no transfer methods
I will connect wallet through unity SDK but I need the user to authenticate in backend too so I can handle transfers of tokens and all using NodeJs
Now I struck with authenticating user in backend
I tried like signup in backend and get the session token and to be passed to frontend
thats not working because I am not able to fetch the session token
Is there any other way to authenticate user in backend with data from the frontend ?
by backend you mean what runs on a mobile phone?
and not on a separate server that you have somewhere?
there is a thread specific to Unity questions: Ethereum Unity3D Boilerplate Questions
not sure why you need authentication to handle transfer of tokens
What I am trying to achieve is to build a wallet for my game. so users can swap using DEX and transfer tokens back and forth inside our app, React boilerplate I tried and it works fine but here I am doing in unity mobile app and so here I saw unity SDK but its fairly new so it doesn’t have transfer function for both tokens and NFTs and DEX it has APIs to only connect wallet and retrieve balances, so I was thinking workaround for this token and NFT transfers, And came across NODEJS support and trying to transfer tokens from one user to another user from server-side to achieve this transfer tokens and DEX. Is there any workaround available that I am trying to achieve here? I thought the user authenticated from mobile and some workaround to do transfer process from backend behaves of the user using session-token is there any method you suggest? I don’t know how the authentication works on the backend
I don’t think that you need the user session to do a transfer. If you have access to a web3 instance then you should be able to do a transfer.
Hi, Then can you tell me how to transfer and swap tokens, we have a mobile app game built on unity, and it connected to metamask using moralis unity Ethereum boilerplate SDK code and there are no functions to transfer tokens in unity SDK like how React Ethereum boilerplate code has transfer tokens and in-build DEX inside the react app.
I don’t know exactly, but if you have access to a web3 instance then you can use that to do a transfer, better to ask in the thread specific to Unity: Ethereum Unity3D Boilerplate Questions
Thanks will try that