Creating Test User Account - Discussion

Okay Sounds good and looking forward to that Taha.

1 Like

@CryptoCowboy
Currently, Enjin doesnt require email to use wallet, if you want to track email can do it locally i.e. store in your own database for verification purpose.

Thanks for waiting :slight_smile:

2 Likes

@Taha

Okay thank you Taha, I am now handling the players password and email on my own server and now I need to log them into Enjin using only the players “name”. The account manager script uses “email” and “password”. How do I change the account manager script to use “name” instead of “email” and “password”.

EnjinUser user = await EnjinUser.Login(email, password);

1 Like

@CryptoCowboy
Are you asking about Account manager or user?
Because for account manager we are still using email and password for login and authentication.
But for user only name

source: https://docs.enjin.io/creating-account/#logginginandauthenticatingyourrequests

2 Likes

@Taha

I am talking about the AccountManager script. The script works fine for logging in the Admin account that is connected to the wallet daemon. The problem is when I go to create a “test user” the only way I can do that is with “name”. I still get the linking code and everything and connect the “testuser” to the Enjin Wallet. This “testuser” does not have a email or password associated with the Enjin Platform because email and password have been depreciated when creating a new user. I have moved the email and password handling to my own server. What needs to happen now is for the AccountManager script to check if the testuser’s name exist in the Enjin Platform and if so then continue on and if not then create the testuser.

Bellow is the only mutation that works for creating a new player, since email and password have been depreciated.
mutation createNewUser{ CreateEnjinUser ( name: “testuser” ) { id name accessTokens } }

@CryptoCowboy

Yes, I am aware of the depreciation and also testing the create user mutation

Since, email and password is no longer needed, you only have to use name param.

Check below:

 query AuthPlayer($name: String!) {
  AuthPlayer(id: $name) {
    accessToken
    expiresIn
  }
}

source: https://docs.enjin.io/creating-your-integration/#step5logginyouruserin

Let me know for further queries :slight_smile:

2 Likes

@Taha

 async public void AuthPlayer()
    {
        string name = emailInput.GetComponent<InputField>().text;
        EnjinUsers user = await EnjinUsers.AuthPlayer(name);
        EnjinIdentities userIdendityOption = await user.GetIdentityForAppId(_appID);

        EnjinIdentities userIdentity = userIdendityOption.Reduce(() => {
            throw new System.Exception("User Identity not Found");

        });

        GoToGame();
    }

This is my attempt at converting the “Login” to “AuthPlayer” using the new SDK. This script is non - functional. If you have a better way please let me know and thank you.

@CryptoCowboy

I am seeing emailInput and not name

Step 1: you can try the query in GraphQL playground.

Step 2: Are you getting any error message? Try debugging in js.

Orelse it will be best to share your code base on GitHub?

2 Likes

@Taha

Basically looking over at the Enjin forum on this and its looking like this is important,

query AuthPlayer($name: String!) {
AuthPlayer(id: $name) {
accessToken
expiresIn
}
}

I was able to authorize the player with only their name via the graphql playground and so the question is how to implement this into the AccountManager script.

1 Like

Yes,
I have mentioned the same here :slight_smile:

I will write down the program sample and get back to you

2 Likes
 query AuthPlayer($name: String!) {
  AuthPlayer(id: $name) {
    accessToken
    expiresIn
  }
}

Is there any way to make the name kyanisthebest and then how do i log in to the account?
@Taha
@filip

1 Like

Because i am not seeing any password thing in the code nor e-mail so i dont know how to log-in
@Taha
@filip

same here @Taha, @filip etc . Now I only have a new testUser username (no email or password set, or even settable AFAIK) created in my app on kovan enjin, successfully linked to my enjin wallet app. I can’t figure out what to change in AccountManager.cs to get my testUser logged in to the game. There is no email address or password to pass to EnginUser.Login() any more, and there is no obvious AuthPlayer() function in the SDK to pass my testUser username to instead.

Please help! thanks

1 Like

Hey @Billy, hope you are great.

I tried with:

mutation newUser{
  CreateEnjinUser(name:"test1"){
    id accessTokens
  }
}

query viewIdentities{ 
  EnjinIdentities ( pagination: { page: 1, limit: 50 } ) { 
  id app {name} 
  linking_code enj_allowance ethereum_address 
	} 
}

My result on GraphQL was valid, so i suggets you to try it the same way also. Let me know if works for you. :nerd_face:

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

Hi @thecil yes I can create the user and link a wallet and see the new identity ok in GraphQL. What I can’t see in the AccountManager.cs code is a way to authenticate this user against the Enjin database (“log them into the game”). Can’t the Enjin SDK for Unity do this game user authentication function any more?

@KYNUX @CryptoCowboy sorry to interrupt, did either of you get an actual solution to this from @Taha or anyone else, that gets a new EnjinUser / EnjinIdentity back into the AccountManager.cs C# script for the test user? Clearly, repeating the same GraphQL instructions is not useful to us in a C# function :slight_smile: thanks!

1 Like

Hey @Billy

Could you please show me where are you downloading the script? Might be an deprecated library, but i want to be sure anyway.

Carlos Z

Sure @thecil it was from https://ivanontech-academy.s3.eu-north-1.amazonaws.com/Enjin-course/EnjinRefactoredSDK-academy.unitypackage
Thanks

Did you manage to figure this one out? I have the same problem, there’s no documentation for Unity SDK API. I have no idea which functions there are outside of the ones @filip used in the course and so there’s no way in me being able to know how to authenticate to a specific User in C# Unity after logging in via email and password. :slightly_frowning_face:

1 Like

sort of. As per Improvement Suggestions - Discussion, I ended up downloading and using the more current SDK from the Asset Store. Then I figured out they seem to have done away with “in-Enjin” authentication in the SDK so you have to implement it yourself in your own code or some other server you run somewhere with some kind of user/email/password database. For the purposes of this course, you can just fake it and assume any old password is acceptable and then just grab the user’s details from Enjin without “logging them in”. My ‘login’ code for the newer SDK:

public static AccountManager instance;

    // Start is called before the first frame update
    void Start()
    {
        if (AccountManager.instance == null) {
            AccountManager.instance = this;
        }

      StartPlatform(PLATFORM_URL, APP_ID, APP_SECRET); // New SDK init method
      LoginAdmin();
    }

    // Update is called once per frame
    void Update()
    {

    }

async public void LoginAdmin() {
  adminIdentity = GetIdentity(9535);  // My game Admin id
  Debug.Log(adminIdentity.id);
}

  async public void Login() {
    string email = emailInput.GetComponent<InputField>().text;
    string password = passwordInput.GetComponent<InputField>().text;
    User user =  GetUser(email); //Assume password ok and just get user details from Enjin SDK
    Debug.Log(user.identities[0]);

    userIdentity = user.identities[0];
    Debug.Log(userIdentity.id);

    SceneManager.LoadScene("MainScene");

  }

HTH, cheers!

2 Likes