AddAuthParameter() 공개 메소드

Adds a key-value pair to the get-parameters used for Custom Auth.
This method does uri-encoding for you.
public AddAuthParameter ( string key, string value ) : void
key string Key for the value to set.
value string Some value relevant for Custom Authentication.
리턴 void
예제 #1
1
    // Use this for initialization
    void Start()
    {
        loadBalancingClient = new LoadBalancingClient(null, TurnbasedAppId, "1.0"); // the master server address is not used when connecting via nameserver

        AuthenticationValues customAuth = new AuthenticationValues();
        customAuth.AddAuthParameter("username", UserName);  // expected by the demo custom auth service
        customAuth.AddAuthParameter("token", UserToken);    // expected by the demo custom auth service
        loadBalancingClient.AuthValues = customAuth;

        loadBalancingClient.AutoJoinLobby = false;
        loadBalancingClient.ConnectToRegionMaster("us");
    }
예제 #2
0
 public PhantomClient(string token, string user, string avatar) : base(ConnectionProtocol.Udp)
 {
     ClientIndex    = GeneralUtils.Clients.Count();
     Token          = token;
     User           = user;
     Avatar         = avatar;
     AppId          = "bf0942f7-9935-4192-b359-f092fa85bef1";
     NameServerHost = "ns.exitgames.com";
     AppVersion     = ClientUtils.GetCurrentReleaseServer() + "_2.5";
     AuthValues     = new AuthenticationValues()
     {
         AuthType = CustomAuthenticationType.Custom
     };
     AuthValues.AddAuthParameter("token", Token);
     AuthValues.AddAuthParameter("user", User);
     this.RegisterTypes();
     ConsoleUtils.Log($"[Client #{ClientIndex}] Created new PhantomClient");
     AddCallbackTarget(this);
     ConsoleUtils.Log($"[Client #{ClientIndex}] Subscribed to Client Callbacks");
     ConsoleUtils.Log($"[Client #{ClientIndex}] Connecting to Region Master USW");
     new Thread(() => UpdateThread())
     {
         IsBackground = true
     }.Start();
     ConnectToRegionMaster("USW");
 }
예제 #3
0
    /*
     * Step 3
     * This is the final and the simplest step. We create new AuthenticationValues instance.
     * This class describes how to authenticate a players inside Photon environment.
     */
    private static void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult obj)
    {
        LogMessage("Photon token acquired: " + obj.PhotonCustomAuthenticationToken + "  Authentication complete.");

        //We set AuthType to custom, meaning we bring our own, PlayFab authentication procedure.
        var customAuth = new AuthenticationValues {
            AuthType = CustomAuthenticationType.Custom
        };

        //We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
        customAuth.AddAuthParameter("username", _playFabPlayerIdCache);    // expected by PlayFab custom auth service

        //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        customAuth.AddAuthParameter("token", obj.PhotonCustomAuthenticationToken);

        //We finally tell Photon to use this authentication parameters throughout the entire application.
        PhotonNetwork.AuthValues = customAuth;
        //
        PhotonNetwork.AuthValues.UserId = _playFabPlayerIdCache;
        //
        //UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(0);
        PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.none);
        if (OnLoginSuccess != null)
        {
            OnLoginSuccess(string.Format("SUCCESS: {0}", "result.SessionTicket"), MessageDisplayStyle.error);
        }

        Debug.Log("AuthenticateWithPhoton");
    }
예제 #4
0
    private void ConnectToMasterServer(string id, string ticket)
    {
        //Debug.Log("connect to master server");
        //if (PhotonNetwork.AuthValues != null)
        //{

        //}
        //else
        //{

        //    PhotonNetwork.AuthValues = new AuthenticationValues()
        //    {

        //        AuthType = CustomAuthenticationType.Custom

        //    };

        //    PhotonNetwork.AuthValues.AddAuthParameter(id, ticket);

        //}

        AuthenticationValues authVals = new AuthenticationValues(AuthManager.playfabId);

        authVals.AuthType = CustomAuthenticationType.Custom;
        authVals.AddAuthParameter("username", AuthManager.playfabId);
        authVals.AddAuthParameter("token", ticket);

        PhotonNetwork.ConnectUsingSettings("1.0");
    }
        public void Initialize(string UserId, string NickName)
        {
                        #if CONFIG_LIVE
            PhotonNetwork.logLevel = PhotonLogLevel.ErrorsOnly;
                        #else
            PhotonNetwork.logLevel = PhotonLogLevel.Informational;
                        #endif

            PhotonNetwork.autoJoinLobby          = false;
            PhotonNetwork.automaticallySyncScene = false;
            PhotonNetwork.BackgroundTimeout      = 500f;

            PhotonNetwork.MaxResendsBeforeDisconnect = 10;
            PhotonNetwork.QuickResends        = 3;
            PhotonNetwork.sendRate            = 2;
            PhotonNetwork.sendRateOnSerialize = 2;
            AuthenticationValues auth = new AuthenticationValues();

            auth.AuthType = CustomAuthenticationType.None;
            auth.AddAuthParameter("UserId", UserId);
            auth.AddAuthParameter("access_token", "offlien_token");                     //this token isn't required as yet.

            PhotonNetwork.playerName        = NickName;
            PhotonNetwork.AuthValues        = auth;
            M3Utils.Instance.GameRestarted += OnGameRestart;
            PhotonNetwork.OnEventCall      += OnEventCall;
        }
예제 #6
0
    private void OnPhotonAuthenticationSuccess(GetPhotonAuthenticationTokenResult obj)
    {
        Logger.Verbose("MainPageScript.OnPhotonAuthenticationSuccess");

        // Set the Photon Connection Settings
        // See https://api.playfab.com/docs/using-photon-with-playfab/
        PhotonNetwork.PhotonServerSettings.AppID           = PhotonAppID;
        PhotonNetwork.PhotonServerSettings.HostType        = ServerSettings.HostingOption.PhotonCloud;
        PhotonNetwork.PhotonServerSettings.PreferredRegion = CloudRegionCode.us;
        PhotonNetwork.PhotonServerSettings.Protocol        = ExitGames.Client.Photon.ConnectionProtocol.Udp;

        string authToken = obj.PhotonCustomAuthenticationToken;

        AuthenticationValues customAuth = new AuthenticationValues();

        customAuth.AuthType = CustomAuthenticationType.Custom;
        customAuth.AddAuthParameter("username", PlayFabManager.PlayfabId);    // expected by PlayFab custom auth service
        customAuth.AddAuthParameter("token", authToken);                      // expected by PlayFab custom auth service

        JUMPOptions.GameVersion = AppID;
        JUMPOptions.CustomAuth  = customAuth;

        // Now Activate the JUMP Connection object that will trigger login to Photon.
        JUMPConnectionStatus = JUMPConnectionStatus.Connecting;
        JUMPConnection.gameObject.SetActive(true);
    }
예제 #7
0
    private void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult obj)
    {
        LogMessage("Photon token acquired: " + obj.PhotonCustomAuthenticationToken + "  Authentication complete.");

        //We set AuthType to custom, meaning we bring our own, PlayFab authentication procedure.
        var customAuth = new AuthenticationValues {
            AuthType = CustomAuthenticationType.Custom
        };

        //We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
        customAuth.AddAuthParameter("username", PlayFabAuthService.PlayFabId);    // expected by PlayFab custom auth service

        //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        customAuth.AddAuthParameter("token", obj.PhotonCustomAuthenticationToken);

        //We finally tell Photon to use this authentication parameters throughout the entire application.
        PhotonNetwork.AuthValues = customAuth;

        if (!PhotonNetwork.IsConnected)
        {
            PhotonNetwork.ConnectUsingSettings();
        }

        PhotonNetwork.LocalPlayer.NickName = (PlayFabAuthService.PlayFabId.Split(new Char[] { '-' }))[0];
        SetLobbyPanelActive();
    }
예제 #8
0
    private void OnPhotonTokenReceived(GetPhotonAuthenticationTokenResult result)
    {
        Debug.Log("Received photon token");

        //We set AuthType to custom, meaning we bring our own, PlayFab authentication procedure.
        var customAuth = new AuthenticationValues {
            AuthType = CustomAuthenticationType.Custom
        };

        //We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
        customAuth.AddAuthParameter("username", PlayerId);    // expected by PlayFab custom auth service

        //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        customAuth.AddAuthParameter("token", result.PhotonCustomAuthenticationToken);

        //We finally tell Photon to use this authentication parameters throughout the entire application.
        PhotonNetwork.AuthValues = customAuth;

        //Finally we will initialize photon with any custom data
        InitializePhoton();

        if (OnLogin != null)
        {
            OnLogin();
        }
    }
예제 #9
0
    private void AuthSuccessCallback(string UserID)
    {
        LoginMsg.text = "Auth Success";

        SystemManage.GetAllTitleData();                 //取得所有title data
        SystemManage.GetAllStroeItem();                 //取得所有物品

        //使用playfab登入photon
        PlayFabClientAPI.GetPhotonAuthenticationToken(new GetPhotonAuthenticationTokenRequest()
        {
            PhotonApplicationId = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime
        }, (xr) =>
        {
            var customAuth = new AuthenticationValues {
                AuthType = CustomAuthenticationType.Custom
            };

            customAuth.AddAuthParameter("username", UserID);
            customAuth.AddAuthParameter("token", xr.PhotonCustomAuthenticationToken);

            PhotonNetwork.AuthValues = customAuth;
            PhotonNetwork.ConnectUsingSettings();

            LoginMsg.text = "Login....";
        },
                                                      (xe) =>
        {
            LoginMsg.text = "Login Fail";
            ModalHelper.WarningMessage("Photon Authentication fail.");
        });
    }
    private void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult obj)
    {
        LogMessage("Photon token acquired: " + obj.PhotonCustomAuthenticationToken + "  Authentication complete.");
        var customAuth = new AuthenticationValues {
            AuthType = CustomAuthenticationType.Custom
        };

        customAuth.AddAuthParameter("username", _playFabPlayerIdCache);
        customAuth.AddAuthParameter("token", obj.PhotonCustomAuthenticationToken);
        PhotonNetwork.AuthValues = customAuth;
        LoginScene.Instance.LoginClick();
    }
예제 #11
0
    void OnAuthTokenResult(GetPhotonAuthenticationTokenResult result)
    {
        AuthenticationValues customAuth = new AuthenticationValues();

        customAuth.AuthType = CustomAuthenticationType.Custom;
        customAuth.AddAuthParameter("username", playfabId);
        customAuth.AddAuthParameter("token", result.PhotonCustomAuthenticationToken);

        PhotonNetwork.AuthValues = customAuth;

        PhotonNetwork.ConnectUsingSettings("v0.1d");
    }
예제 #12
0
    // Use this for initialization
    void Start()
    {
        loadBalancingClient = new LoadBalancingClient(null, TurnbasedAppId, "1.0"); // the master server address is not used when connecting via nameserver

        AuthenticationValues customAuth = new AuthenticationValues();

        customAuth.AddAuthParameter("username", UserName);  // expected by the demo custom auth service
        customAuth.AddAuthParameter("token", UserToken);    // expected by the demo custom auth service
        loadBalancingClient.AuthValues = customAuth;

        loadBalancingClient.ConnectToRegionMaster("eu");
    }
예제 #13
0
    public void Connect()
    {
        _loadBalancingClient.UserId = _userToken;
        AuthenticationValues customAuth = new AuthenticationValues(_loadBalancingClient.UserId);

        customAuth.AuthType = CustomAuthenticationType.Custom;
        customAuth.AddAuthParameter("username", _userName);          // expected by the demo custom auth service
        customAuth.AddAuthParameter("token", _userToken);            // expected by the demo custom auth service
        _loadBalancingClient.AuthValues = customAuth;
        _loadBalancingClient.NickName   = _userName;

        _loadBalancingClient.AutoJoinLobby = false;
        _loadBalancingClient.ConnectToRegionMaster("eu");
    }
예제 #14
0
    public void ConnectToMasterServer(string id, string ticket)
    {
        AuthenticationValues customAuth = new AuthenticationValues();
        customAuth.AuthType = CustomAuthenticationType.Custom;
        customAuth.AddAuthParameter("username", id);    // expected by PlayFab custom auth service
        customAuth.AddAuthParameter("token", ticket);   // expected by PlayFab custom auth service

        this.GameInstance.AuthValues = customAuth;

        //this.GameInstance.AutoJoinLobby = false;                      // use this, if you don't list current rooms
        this.GameInstance.loadBalancingPeer.QuickResendAttempts = 2;    // option to re-send reliable stuff more quickly
        this.GameInstance.loadBalancingPeer.SentCountAllowance = 8;     // default + some quick resends

        this.GameInstance.ConnectToRegionMaster("US");  // connect to the US region of Photon Cloud
    }
    void AuthenticatewithPhoton(GetPhotonAuthenticationTokenResult result)
    {
        Notify.text = "Photon token acquired Authentication complete.";

        var customAuth = new AuthenticationValues
        {
            AuthType = CustomAuthenticationType.Custom
        };

        customAuth.AddAuthParameter("username", PlayfabId);
        customAuth.AddAuthParameter("token", result.PhotonCustomAuthenticationToken);

        PhotonNetwork.AuthValues = customAuth;

        SceneManager.LoadScene(1);
    }
예제 #16
0
    private void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult obj)
    {
        string gamever = MainMenu.GameVersion;

        gamever = gamever.Replace(".", "_");
        gamever = gamever.Replace(" ", "_");
        Debug.Log("Photon token acquired: " + obj.PhotonCustomAuthenticationToken);
        Debug.Log("Authentication complete playfabID " + _playFabPlayerIdCache);

        //We set AuthType to custom, meaning we bring our own, PlayFab authentication procedure.
        var customAuth = new AuthenticationValues {
            AuthType = CustomAuthenticationType.Custom
        };

        //We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
        customAuth.AddAuthParameter("username", _playFabPlayerIdCache);            // expected by PlayFab custom auth service
        customAuth.UserId = PlayerName;
        //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        customAuth.AddAuthParameter("token", obj.PhotonCustomAuthenticationToken);

        //We finally tell Photon to use this authentication parameters throughout the entire application.
        PhotonNetwork.AuthValues = customAuth;

        ZPlayerPrefs.SetString("playfabId", _playFabPlayerIdCache);
        ZPlayerPrefs.SetString("token", obj.PhotonCustomAuthenticationToken);
        ZPlayerPrefs.SetString("username", Email);
        ZPlayerPrefs.SetString("passd", Password);

        PlayerData data = new PlayerData();

        localPlayerDataObject.GetComponent <LocalPlayerData> ().LoadData(data);
        data.name   = Email;
        data.logout = false;
        data.auth   = AuthMethod;
        localPlayerDataObject.GetComponent <LocalPlayerData> ().SaveData(data);

        PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
        {
            FunctionName      = "ClientLogin",
            FunctionParameter = new {
                game_version = gamever
            },
            GeneratePlayStreamEvent = true,
        }, OnCloudScriptSuccess, OnCloudScriptFail
                                            );
    }
예제 #17
0
    public void ConnectToMasterServer(string id, string ticket)
    {
        AuthenticationValues customAuth = new AuthenticationValues();

        customAuth.AuthType = CustomAuthenticationType.Custom;
        customAuth.AddAuthParameter("username", id);    // expected by PlayFab custom auth service
        customAuth.AddAuthParameter("token", ticket);   // expected by PlayFab custom auth service

        this.GameInstance.AuthValues = customAuth;

        //this.GameInstance.AutoJoinLobby = false;                      // use this, if you don't list current rooms
        this.GameInstance.loadBalancingPeer.QuickResendAttempts = 2;    // option to re-send reliable stuff more quickly
        this.GameInstance.loadBalancingPeer.SentCountAllowance  = 8;    // default + some quick resends


        this.GameInstance.ConnectToRegionMaster("US");  // connect to the US region of Photon Cloud
    }
예제 #18
0
        /*
         * Step 3
         * This is the final and the simplest step. We create new AuthenticationValues instance.
         * This class describes how to authenticate a player inside Photon environment.
         */
        private static void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult obj)
        {
            Debug.Log("Photon token acquired: " + obj.PhotonCustomAuthenticationToken + "  Authentication complete.");

            //We set AuthType to custom, meaning we bring our own, PlayFab authentication procedure.
            var customAuth = new AuthenticationValues {
                AuthType = CustomAuthenticationType.Custom
            };

            //We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
            customAuth.AddAuthParameter("username", PlayerPrefs.GetString("playFabId"));    // expected by PlayFab custom auth service

            //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
            customAuth.AddAuthParameter("token", obj.PhotonCustomAuthenticationToken);

            //We finally tell Photon to use this authentication parameters throughout the entire application.
            PhotonNetwork.AuthValues = customAuth;
        }
예제 #19
0
    /*
     * Step 3
     * This is the final and the simplest step. We create new AuthenticationValues instance.
     * This class describes how to authenticate a players inside Photon environment.
     */
    private void AuthenticationWithPhoton(GetPhotonAuthenticationTokenResult _obj)
    {
        LogMessage("Photon token acuired: " + _obj.PhotonCustomAuthenticationToken + " Authentication complete.");

        // We set AuthType to custom, meaning we bring our own, PlayFab authentication procedure.
        var _customAuth = new AuthenticationValues {
            AuthType = CustomAuthenticationType.Custom
        };

        // We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID(!) and not username.
        _customAuth.AddAuthParameter("username", playFabPlayerIdCache);         // Expected by PlayFab custom auth service

        // We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issue to your during previous step.
        _customAuth.AddAuthParameter("token", _obj.PhotonCustomAuthenticationToken);

        // We finally tell Photon to use this authentication parameters throughout the entire application.
        PhotonNetwork.AuthValues = _customAuth;
    }
예제 #20
0
    void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult tokenResult)
    {
        Debug.Log("Photon token acquired: " + tokenResult.PhotonCustomAuthenticationToken + "  Authentication complete.");

        var customAuth = new AuthenticationValues {
            AuthType = CustomAuthenticationType.Custom
        };

        //We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
        customAuth.AddAuthParameter("username", PlayFabId);        // expected by PlayFab custom auth service

        //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        customAuth.AddAuthParameter("token", tokenResult.PhotonCustomAuthenticationToken);

        Debug.Log("USerid in custom auth " + customAuth.UserId);
        //We finally tell Photon to use this authentication parameters throughout the entire application.
        PhotonNetwork.AuthValues = customAuth;
        OnGetPhotonAuthenticationTokenResult.OnNext(tokenResult);
        GetPlayerProfile(PlayFabId);
    }
예제 #21
0
    private void AuthenticateWithPhoton(GetPhotonAuthenticationTokenRequest obj)
    {
        LogMessage("Photon token acquired: " + obj.PhotonCustomAuthenticationToken + " Authentication comeplete.");

        var customAuth = new AuthenticationValues {
            AuthType = CustomAuthenticationType.Custom
        };

        customAuth.AddAuthParameter("username", _playFabPlayerIdCache);

        PhotonNetwork.AuthValues = customAuth;

        PhotonNetwork.ConnectUsingSettings();
    }
예제 #22
0
    private void ConnectToMasterServer(string id, string ticket)
    {
        //Debug.Log("connect to master server");
        //if (PhotonNetwork.AuthValues != null)
        //{

        //}
        //else
        //{

        //    PhotonNetwork.AuthValues = new AuthenticationValues()
        //    {

        //        AuthType = CustomAuthenticationType.Custom

        //    };

        //    PhotonNetwork.AuthValues.AddAuthParameter(id, ticket);

        //}

        AuthenticationValues authVals = new AuthenticationValues(AuthManager.playfabId);
        authVals.AuthType = CustomAuthenticationType.Custom;
        authVals.AddAuthParameter("username", AuthManager.playfabId);
        authVals.AddAuthParameter("token", ticket);

        PhotonNetwork.ConnectUsingSettings("1.0");

    }