PlayFab Integration
Introduction
In this document we help you integrate PlayFab with Photon.
With this approach, both systems will get used in parallel to their full potential.
Billing is separate for each service.
Read PlayFab's Photon Quickstart here.
Below are the setup instructions for Photon.
Custom Authentication
Dashboard Configuration
Here are the steps to setup custom authentication with PlayFab:
- Go to Photon dashbaord.
- Choose an application or create a new one.
- Click "Manage".
- Under "Authentication" section, click "Custom Server".
- [Required] Set Authentication URL to
https://{PlayFabTitleId}.playfabapi.com/photon/authenticate
.
Make sure to replace{PlayFabTitleId}
placeholder with your actual PlayFab TitleId.
Do not keep the open ({
) and closing (}
) braces or curly brackets characters in the URL.
Example: if your PlayFab TitleId isAB12
:https://AB12.playfabapi.com/photon/authenticate
. - Save by hitting "Create".
- [Recommended] Untick "Allow anonymous clients to connect, independently of configured providers".
Client Code
Client is expected to send a pair of key/values as credentials:
- PlayFab UserId of the logged in user.
- Photon token (retrieved using GetPhotonAuthenticationToken Client API method).
C#
chatClient.AuthValues = new AuthenticationValues();
chatClient.AuthValues.AuthType = CustomAuthenticationType.Custom;
chatClient.AuthValues.AddAuthParameter("username", PlayFabUserId);
chatClient.AuthValues.AddAuthParameter("token", PlayFabPhotonToken);
chatClient.AuthValues.UserId = userId; // UserId is always required in Photon Chat
// do not set AuthValues.Token or authentication will fail
// connect
C++
ExitGames::Common::JString params = "username="+PlayFabUserId+"&token="+PlayFabPhotonToken;
ExitGames::Chat::AuthenticationValues playFabAuthenticationValues;
playFabAuthenticationValues.setType(ExitGames::Chat::CustomAuthenticationType::CUSTOM).setParameters(params);
// pass playFabAuthenticationValues as parameter on connect
JavaScript
var queryString = "username="+playFabUserId+"&token="+playFabPhotonToken;
chatClient.setCustomAuthentication(queryString, Photon.LoadBalancing.Constants.CustomAuthenticationType.Custom);
// connect
Back to top