Replicated variables on login

Hi guys.

I have got EOS/EAS to work in a simple project, and now if I understand it right I can get an auth token of some type. My question is, on connecting to a server, how can I send it and set it as a replicated variable? To let the server know who the client is, what data to load and other clients to know the name of them.

Auth token should remain secret.
If you have set up EOS properly, then when connecting to a server, they should already know everything about the connected player.

Players will already have their custom name assigned to them. You just have to use the correct method (APlayerState::GetPlayerName).

A player will have a Unique Net ID. The server and other clients can use this Net ID with certain functions within the Online Subsystem (i.e. through Online::GetIdentityInterface) to get any further information.
Some info will not be retrievable as it is designed not to be shared with others (you can change this to some extent in EOS Developer Portal).
You can store some of this further info in PlayerState if you wish, just for ease of use, but it is not necessary.

I want to get the Epic Account ID of the player, and do it with validating the data using the auth token (the JWT one). How may I validate it on the server side? I mean, when is it passed, in PreLogin maybe? And how can I get the Epic ID of the player later in the gameplay, from the server?
I want to avoid users setting their epic account id from client-side. and acting on others behalf.

I’m fairly certain EOS has the ability to authenticate. But in case your paranoid, you CAN send the Auth token as an Option when you join a server (you know when you do ‘?listen’, you can do the same thing for the client but ‘?auth={AuthToken}’ instead.
I believe in PreLogin (maybe Login), you have access .to the client’s Options. You can then retrieve the Auth Option you are looking for and save it within a Map within the GameMode.
I forgot the exact library which lets you parse options, maybe something like ‘UGameplayStatics::ParseOption’?

As for getting the Epic ID, I am pretty sure the Unique Net ID is the Epic ID. Could be wrong tho. It could just be an ID which can then give you the Epic ID using the Identity Interface.

1 Like

As far as I know, the Epic Account ID can be retrieved from the token, with the SDK functions to verify it (and then can be trusted, because the JWT token “sub” is always trusted.)
EOS and EAS are really poorly implemented into UE.
In PreLogin I don’t know (yet) how to add custom options to connecting, say from a Main Menu I want the client to join the dedicated server and send the auth token which would be verified by the SDK. This process should also set a variable to the player, like an Epic account id if the Unique Net Id does not contain the same.
The only question left is how can I make a client connect with options to a specific dedicated server (From blueprints or C++ code does not really matter since the authentication is already cpp).

E:
Found this on the old wiki, Passing Arguments To Server During Connection - Old UE4 Wiki.

Seems to solve the problem, passing the option and getting it on server, verifying the token and setting a replicated variable of EpicAccountId/Name/etc. Being paranoid isn’t the reason, I’ve learnt the lesson back years ago, never trust data coming from a client: DO NOT set the EpicAccID directly because the client said so.

That wiki details exactly what I was trying to say.
You can also do in BP by using the Execute Command node.

I haven’t really delve into authentication. I just assumed Unreal’s Online Subsystem did that for you since it is a relatively crucial part of online multiplayer.

1 Like