Closed jquentin-lion closed 2 years ago
Can you please provide the full error details on what comes back from the server? Also what version of the game server and what version of the JS SDK are you using?
The exception thrown: Response {type: 'cors', url: 'http://serverIP:7350/v2/account/link/email?', redirected: false, status: 400, ok: false, …} body: (...) bodyUsed: false headers: Headers {} ok: false redirected: false status: 400 statusText: "Bad Request" type: "cors" url: "http://serverIP:7350/v2/account/link/email?"
Server version: 3.9.0+6f4c456b nakama-js@2.3.0
Can you please open the body and JSON decode and print it?
Not sure how to do that. I'm getting this when expanding the body: body: ReadableStream locked: false
cancel: ƒ cancel() getReader: ƒ getReader() locked: false pipeThrough: ƒ pipeThrough() pipeTo: ƒ pipeTo() tee: ƒ tee() constructor: ƒ ReadableStream() Symbol(Symbol.toStringTag): "ReadableStream" get locked: ƒ locked()
So the body's json seems to be: {locked: false} Is that what you wanted?
That doesn’t seem like a response error sent by Nakama. Is it possible for you to zip up your project and either email it to me and upload it here in GH?
Here's a simple sample to demonstrate the issue: https://drive.google.com/file/d/1GbcTz0tqULN2GOZTejMSQyVn76aTkE3M/view?usp=sharing And here it is uploaded to my www for testing: http://jeremyquentin.fr/NakamaTest/
Hi @jquentin-lion - Just had a chance to look at the sample code you've sent through; Thanks for the code examples, it was really helpful.
A couple of things:
try {
const session = await client.authenticateEmail(email, password, create, "testusername");
} catch(e) {
e.text().then(errMsg => console.log("error": errMessage)) // you can also try e.json()...
}
Instead of:
await client.linkEmail(session, email, password);
you should:
await client.linkEmail(session, {email: email, password: password});
I've tested this and it works now locally. If this solves the issue, kindly close the issue.
@mofirouz I see. I'll try this. Thanks. Is there somewhere we can find these function signatures?
This will be published soon on the main website documentation, but in the meantime you can find the client api docs here: https://heroiclabs.github.io/nakama-js/classes/Client.html#linkEmail
@mofirouz That does seem to work! Thanks!
Now there is one other problem: it's that authenticateEmail with create=false throws
POST http://Ser.ver.IP:7350/v2/account/authenticate/email?create=false&username=testusername& 404 (Not Found)
Even though authenticateEmail is in a try block.
It's not blocking because it works when the account is found, but it doesn't sound like an intended behaviour.
Should I create a new issue for this, as it's not really related?
Sorry a tad bit lost - When an account is not found, and you try to AuthEmail with Create=false, the server returns a 404 and the client returns an error?
If my understanding is correct, the behaviour is correct too (though unsure about 404 vs 401).
Can you clarify what you mean?
I guess that might be the correct behaviour internally. In that case, the only thing is that the 404 is printed in the browser's console, even if it's caught by a try catch.
I think what you are seeing is the browser's default request logger into the console when the console is open. There isn't any printing in the SDK.
If I call
await client.linkEmail(session, email, password);
It raises an error code 400 - Bad Request. The email is not already in use in another account. authenticateEmail with create=true works. Calling LinkEmailAsync with Unity client on the same server works.