question

Soloman Northrop avatar image
Soloman Northrop asked

Get PlayFab ID From Twitch ID

Is there really no way to get a playfab user by their twitch ID?

I've linked a user's twitch account with their playfab account. I now need to (from a server-side background task) use the user's twitch ID to retrieve their playfab user account details. Is this currently impossible? Is there some other way to do this?

Thanks!

Account Management
1 comment
10 |1200

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

Soloman Northrop avatar image Soloman Northrop commented ·

I should add that the "background task" is actually a twitch webhook so it's not actually linked to a request. Therefore I cannot use a token. All I have access to is the twitch user ID.

0 Likes 0 ·

1 Answer

·
Soloman Northrop avatar image
Soloman Northrop answered

I came up with an short term solution:

1. Add this to your cloud script:

handlers._twitchGenericId = function(args, context) {
    var request = {
        PlayFabId: currentPlayerId
    };
    var result = server.GetUserAccountInfo(request);
    if (result["UserInfo"] && result["UserInfo"]["TwitchInfo"])
    {
        server.AddGenericID({
           PlayFabId: currentPlayerId,
           GenericId: {
               ServiceName: "Twitch",
               UserId: result["UserInfo"]["TwitchInfo"]["TwitchId"]
           }
        });
    }
}

2. Add a new segment with the following arguments:

3. Add an "Entered Segment" action of type "Execute Cloud Script" and select your cloud script.

4. Then whenever you're asking for the user on the server, use https://[yourTitleId].playfabapi.com/Server/GetPlayFabIDsFromGenericIDs

Make sure your body is setup like this:

{
    "GenericIDs": [
        {
            "ServiceName": "Twitch",
            "UserId": 204940653
        }
    ]
}

--------------------------------------

Now, whenever you get a response for the generic ID, you'll get back the user's playfab ID.

While this is nice, it's not an official solution, I'd much prefer there be a way to grab the playfab ID from twitch user ID on the server; just like you can with all the other services.


xazya.png (50.2 KiB)
o6ngl.png (49.2 KiB)
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.

Citrus Yan avatar image Citrus Yan commented ·

You can make a feature request of adding GetPlayFabIDsFromTwitchIDs into the server API set in here: https://community.playfab.com/spaces/24/index.html, that would help you for your case.

1 Like 1 ·
Soloman Northrop avatar image Soloman Northrop Citrus Yan commented ·

Thank you! I hope to hear back. This would be extremely helpful for us :) (idea here)

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.