question

Thomas Brown avatar image
Thomas Brown asked

Is there a way to get current server time with a login requst?

As of now it looks like in order to get the current server time I have to make two separate calls when logging in.

One call to actually login and then the other to get the server time. I'm using this to get the time, but I was hoping that the time data could just be returned by any login call.

After some digging I stumbled upon this this but I'm not getting the time back in the query.

Any help would be appreciated. Thanks in advance!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Technically, the server time is returned as part of the header info on every response. Whether or not the headers are available to your client code is going to depend upon your http library, but if you try the calls in Postman, you can see the "Date" header on every response.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thomas Brown avatar image Thomas Brown commented ·

Ah I did see that in postman, unfortunately it doesn't look like that's going to be available to me in Unity.

Is there any plans to pass that information down in the Unity SDK?

Thanks in advance!

0 Likes 0 ·
brendan avatar image brendan Thomas Brown commented ·

That's actually nothing our SDK has control over. The headers should be available from the networking library you're using. For example, if you're using HttpWebRequest in Unity, you can get the response headers from the UnityWebRequest object.

0 Likes 0 ·
Daniel Keele avatar image
Daniel Keele answered

I used the EntityToken to get the server time on login:

System.DateTime? serverTime = loginResult.EntityToken.TokenExpiration?.AddHours(-24);
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.