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!
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.
Answer by Soloman Northrop · Sep 01, 2020 at 02:32 AM
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.
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.
Thank you! I hope to hear back. This would be extremely helpful for us :) (idea here)