AuthenticateWithPassword (Unity)

- Declaration

public static void AuthenticateWithPassword(string server, string email, string password, Action<CavrnusAuthentication> onSuccess, Action<string> onFailure)

- Description

Gets user credentials, allowing you to join valid spaces and make other requests.

onFailure will generally trigger if the user's email or password is invalid, or if they are not connecting to a valid server.

onSuccess provides a CavrnusAuthentication which you can then store/load on your local machine to use on a future run without requiring the user to re-login.

- Sample

using CavrnusSdk.API; using TMPro; using UnityEngine; public class AuthenticateWithPassword : MonoBehaviour { public TMP_InputField UserEmailInput; public TMP_InputField UserPasswordInput; private const string MyServer = "cavrnus.cavrn.us"; public void Authenticate() { CavrnusFunctionLibrary.AuthenticateWithPassword(MyServer, UserEmailInput.text, UserPasswordInput.text, auth => OnAuthComplete(auth), error => OnAuthFailure(error)); } private void OnAuthComplete(CavrnusAuthentication auth) { Debug.Log("Authentication complete! Welcome to Cavrnus!"); } //Generally an invalid email or password private void OnAuthFailure(string error) { Debug.LogError("Failed to login: " + error); } }

Related pages