question

Rafael Souza avatar image
Rafael Souza asked

Player authentication for authoritative server

I'm making my authorative server with Photon Server and I need to check the user session token before allowing him to join the game, I tried making a post request to ".../Authentication/ValidateEntityToken" but I get this error "This API method does not allow anonymous callers.", what is the correct way of doing it?

10 |1200

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

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

Hi, my suggestion is that you use CloudScript to do the Validation for you. In the client, use ExecuteEntityCloudScript or ExecuteCloudScript API to execute CloudScript with a player’s entity token as a parameter. Here is the sample code in CloudScript:

handlers.validateET = function (args) {

    var data = {};

    log.info("Entity Token from client is " + args.et);

    var vetresult = entity.ValidateEntityToken({

        EntityToken: args.et

    });

    return JSON.stringify(vetresult);

};

However, if you want to validate from the client, you must provide your title’s entity token and player’s entity token in order to call Authentication/ValidateEntityToken API. For title entity token, you must get it from Authentication/GetEntityToken API. However, in order to call this API, you must store the developer key in it, which is not secure.

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.

Rafael Souza avatar image Rafael Souza commented ·

Cool, thank you for responding.

What I did at the moment is just calling GetAccountInfo using the X-Authentication token given to the server from the client, if it's a invalid token PlayFab will return an error, and if it's valid I save some time by already getting some info that I would need. Is there any problem by doing this way?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Rafael Souza commented ·

Well, it seems alright to me. In this way you can get the info you need when user’s session is valid and block the user when the session is invalid, kill two birds with one stone, what a brilliant idea!

0 Likes 0 ·

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.