/* * Authenticates the player. * * Note: This is intended to be handled on a managed authentication server due to the fact that * sensitive credentials are involved. Player clients should never handle this themselves. */ public IEnumerator AuthenticatePlayer(string playerName) { Enjin.IsDebugLogActive = true; // Attempt to fetch player from Enjin platform. User player = Enjin.GetUser(playerName); if (Enjin.ServerResponse == ResponseCodes.NOTFOUND) { // Create new player if no result found. player = Enjin.CreatePlayer(playerName); } for (int i = 0; i < player.identities.Length; i++) { Identity identity = player.identities[i]; if (identity.app.id != projectId) { continue; } _playerIdentityId = identity.id; _playerWalletAddress = identity.wallet.ethAddress; _playerLinkingCode = identity.linkingCode; break; } Debug.Log($"Player Identity Id: {_playerIdentityId}"); Debug.Log($"Player Wallet Address: {_playerWalletAddress}"); Debug.Log($"Player Linking Code: {_playerLinkingCode}"); /* * Authenticate the player and cache the access token. * * Note: Normally you will have your own protocol for clients to communicate with your * authentication server using credentials you save in your own database. It is recommended * that you generate a unique ID for your users and associate that with their login * credentials to avoid exposing their private details to a third party (Enjin). */ _playerAccessToken = Enjin.AuthPlayer(playerName); yield return(null); }
public IEnumerator LoginEnjin(string player_email) { PLAYER_EMAIL = player_email; //Enjin.StartPlatformWithToken(PLATFORM_URL, APP_ID, ACCESS_TOKEN); Enjin.IsDebugLogActive = false; User admin = Enjin.GetUser(DEVELOPER_USERNAME); DEVELOPER_ACCESS_TOKEN = Enjin.AccessToken; print(Enjin.CreatePlayer(PLAYER_EMAIL)); User player = Enjin.GetUser(PLAYER_EMAIL); for (int i = 0; i < player.identities.Length; i++) { Identity identity = player.identities[i]; Enjin.CreateIdentity(identity); if (identity.app.id == APP_ID) { PLAYER_IDENTITY_ID = identity.id; PLAYER_ADDRESS = identity.wallet.ethAddress; APP_LINK_CODE = identity.linkingCode; print("_IDENTITY_ID:: " + PLAYER_IDENTITY_ID); print("_ADDRESS::" + PLAYER_ADDRESS); print("_ADDRESS_LENGTH::" + PLAYER_ADDRESS.Length); print("_LINKING_CODE::" + APP_LINK_CODE); } } // Enjin.CreatePlayer(PLAYER_EMAIL); print(Enjin.AuthPlayer(PLAYER_EMAIL)); yield return(null); }