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 Justin Enayat · Aug 20, 2021 at 02:02 AM · apisPlayer DataLeaderboards and StatisticsAccount Management

Converting playfab login system to linked steam system?

Initially, I set my game up to create and reference player profiles via the unique device identifier:

    void Login()
    {
        var request = new LoginWithCustomIDRequest
        {
            CustomId = SystemInfo.deviceUniqueIdentifier,
            CreateAccount = true,
            InfoRequestParameters = new GetPlayerCombinedInfoRequestParams
            {
                GetPlayerProfile = true
            }
        };
        PlayFabClientAPI.LoginWithCustomID(request, OnSuccess, OnError); 

    }

Using this, it all works. But I recently realized the downsides of having it only log in and identify players depending on what device they are using. I'm trying now to have it log the player in via Steam, but I'm having some trouble.

    public string GetSteamAuthTicket()
    {
        byte[] ticketBlob = new byte[1024];
        uint ticketSize;

        HAuthTicket hTicket = SteamUser.GetAuthSessionTicket(ticketBlob, ticketBlob.Length, out ticketSize);
        Array.Resize(ref ticketBlob, (int)ticketSize);
        StringBuilder sb = new StringBuilder();
        foreach (byte b in ticketBlob)
        {
            sb.AppendFormat("{0:x2}", b);
        }
        return sb.ToString();
    }

    void Login()
    {
        if (SteamManager.Initialized)
        {
            PlayFabClientAPI.LoginWithSteam(new LoginWithSteamRequest
            {
                CreateAccount = true,
                SteamTicket = GetSteamAuthTicket()
            }, OnSuccess, OnError);
        }
    }

When using this instead of the first code for logging in, it creates the player in Playfab, however, it does not update the display name, nor does it work with my existing code. This is what I use to send leaderboard data:

        if (levelName == "TestLevel")
        {
            PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
            {
                FunctionName = "SendTimeTestLevel",
                FunctionParameter = new { timeSend = time },
                GeneratePlayStreamEvent = false,
            }, OnCloudUpdateStats, OnErrorShared);
        }

Cloud script it calls:

handlers.SendTimeTestLevel = function (args, context) {
    var request = {
        PlayFabId: currentPlayerId, Statistics: [{
                StatisticName: "TestLevel",
                Value: args.timeSend
            }]
    };
    var playerStatResult = server.UpdatePlayerStatistics(request);
    return{messageValue: "Updated stats for TestLevel"}
};

I have set up all the Steam stuff in the store, such as App ID's, API keys, etc. However, I am pretty new to coding, I'd really appreciate input on how to make it so that the game will log people in and get their player data based on the Steam account they are logged into instead of what device they are using.

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 Justin Enayat · Aug 19, 2021 at 11:10 PM 0
Share

Oh and I must add I have thoroughly searched the internet about this, the documentation(s) did not solve this problem for me. Again I'm new and did not know what to do with the information given in the Playfab/Steam documentation.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Justin Enayat · Aug 20, 2021 at 06:41 PM

I figured it out. This is the working login code:

    void Login()
    {
        if (SteamManager.Initialized)
        {
            var request = new LoginWithSteamRequest
            {
                CreateAccount = true,
                InfoRequestParameters = new GetPlayerCombinedInfoRequestParams
                {
                    GetPlayerProfile = true,
                    GetUserAccountInfo = true
                },
                SteamTicket = GetSteamAuthTicket(),
            }; 
            PlayFabClientAPI.LoginWithSteam(request, OnSuccess, OnError);
        }
    }
Comment

People who like this

0 Show 0 · 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

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

    1 Person is following this question.

    avatar image

    Related Questions

    [Unity] Get Player Country 1 Answer

    How can I convert the timezone in PlayFab? 1 Answer

    Converting PlayFab Info to Player Object 2 Answers

    Simple leaderboard tutorial for Unity? 1 Answer

    The name 'SteamName' does not exist in the current context 1 Answer

    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