hello,
I looked at the c# code on github. it seems that the authenticationContext ctor param is never used.
every request will start with:
var requestContext = request?.AuthenticationContext ?? authenticationContext
but, requestContext will never be used.
request.AuthenticationContext (all of them) are also never used.
I guess it was planned to bind a ServerInstanceAPI to a specific user.
=> I would like that very much.
it would prevent us from having to specify a PlayFabId for every request.
thanks!
Which repository are you referring to?
I believe your guess is correct. InstanceAPI is designed for developer-controlled places to handle multiple users' actions.
Answer by dominiquecanzeri · Jan 03, 2020 at 01:41 PM
hello,
I am talking about this repo: https://github.com/PlayFab/CSharpSDK
You say my guess is correct, but my point was that it doesn't work.
I would have expected this to work:
async Task Test(string titleId, string secretKey) { var playerSettings = new PlayFab.PlayFabApiSettings() { TitleId = titleId, }; var serverSettings = new PlayFab.PlayFabApiSettings() { TitleId = titleId, DeveloperSecretKey = secretKey, }; var client = new PlayFab.PlayFabClientInstanceAPI(playerSettings); var loginResult = await client.LoginWithCustomIDAsync(new PlayFab.ClientModels.LoginWithCustomIDRequest() { CustomId = "myemail@mail.com", CreateAccount = true }); var server = new PlayFab.PlayFabServerInstanceAPI(serverSettings, loginResult.Result.AuthenticationContext); //this server instance is now bound to myemail@mail.com's account var getPlayerProfileResult = await server.GetPlayerProfileAsync(new PlayFab.ServerModels.GetPlayerProfileRequest() { /*no need to specify PlayfabId here, since it is implicit*/}); //error 400: Invalid input parameters (probably missing PlayFabId) }
create a PlayFabServerInstanceAPI bound to a specific client.
maybe I just misunderstand what the authenticationContext argument does.
It is because the request of PlayFab API has nothing to do with AuthenticationContext, there is nothing implicit inside requests (Line 19). In terms of anything that requests are related, please always refer to official API documentation to see the required properties. If you believe it should be a feature request, You may send a thread on Feature Requests forum to improve the SDK.
In the design model of PlayFabInstanceAPI, usually we only keep the instance of it to store a login session and AuthenticationContext is just a place to retrieve this player's session information. Additionally, you can duplicate another instance with AuthenticationContext, for example:
var client2 = new PlayFab.PlayFabClientInstanceAPI(playerSettings,loginResult.Result.AuthenticationContext);