You can authenticate users in your game, removing the need for your users to log in via a web browser. Here is how you can do that:
using Web3 Game Kit v1.2.1 or newer:
try { MoralisUser user = new MoralisUser(); user.username = "mr_awesome@clem.clem"; user.password = "Password1234"; user.email = user.username; Debug.Log("Sign up"); await user.SignUpAsync(); Debug.Log("Do LogIn"); MoralisUser b1 = await Moralis.LogInAsync("mr_awesome@clem.clem", "Password1234"); Debug.Log($"Create user succeeded. SessionToken: {b1.sessionToken}"); } catch (Exception exp) { Debug.LogError($"Create user failed: {exp.Message}"); }
For versions older than 1.2.1, change
MoralisUser user = new MoralisUser();
to
MoralisUser user = Moralis.Create<MoralisUser>();
Please note that "user.SignUpAsync()" only needs to be called once and does not actually log the user in, this only creates the user account.
Once an account is created the "LogInAsync" will authenticate the user and return a user object with session token.
NOTE: Username and Email can be different values. the current values is a test example.
Comments
0 comments
Please sign in to leave a comment.