Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by dominiquecanzeri · Dec 24, 2019 at 08:23 PM ·

c# ServerInstanceAPI: what is the purpose of authenticationContext?

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!

Comment

People who like this

0 Show 1
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SethDu ♦ · Dec 25, 2019 at 07:20 AM 0
Share

Which repository are you referring to?

I believe your guess is correct. InstanceAPI is designed for developer-controlled places to handle multiple users' actions.

1 Reply

· Add your reply
  • Sort: 
avatar image

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.

Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SethDu ♦ · Jan 06, 2020 at 06:29 AM 0
Share

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);

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges