Exemplo n.º 1
0
        /// <summary>
        /// This is an admin call, please do not use this as a normal call. This is not intended to be used to connect to players. Lootlocker does not currently support
        /// username and password login for normal users
        /// </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        /// <param name="onComplete"></param>

        public static void InitialAuthRequest(string email, string password, Action <LootLockerAuthResponse> onComplete)
        {
            if (!CheckInitialized())
            {
                return;
            }
            var data = new LootLockerInitialAuthRequest();

            data.email    = email;
            data.password = password;
            DemoAppAdminRequests.InitialAuthenticationRequest(data, onComplete);
        }
Exemplo n.º 2
0
        public static void InitialAuthenticationRequest(LootLockerInitialAuthRequest data, Action <LootLockerAuthResponse> onComplete)
        {
            string json = "";

            if (data == null)
            {
                return;
            }
            else
            {
                json = JsonConvert.SerializeObject(data);
            }

            EndPointClass endPoint = LootLockerEndPoints.current.initialAuthenticationRequest;

            LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, json, (serverResponse) =>
            {
                var response = new LootLockerAuthResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    response = JsonConvert.DeserializeObject <LootLockerAuthResponse>(serverResponse.text);

                    if (response.mfa_key == null)
                    {
                        LootLockerConfig.current.UpdateToken(response.auth_token);
                    }

                    response.text = serverResponse.text;

                    LootLockerConfig.current.email = data.email;

                    LootLockerConfig.current.password = data.password;

                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, useAuthToken: false, callerRole: LootLocker.LootLockerEnums.LootLockerCallerRole.Admin);
        }
Exemplo n.º 3
0
        protected override void RefreshTokenAndCompleteCall(LootLockerServerRequest cacheServerRequest, Action <LootLockerResponse> OnServerResponse)
        {
            var authRequest = new LootLockerInitialAuthRequest();

            authRequest.email    = activeConfig.email;
            authRequest.password = activeConfig.password;

            LootLockerAPIManagerAdmin.InitialAuthenticationRequest(authRequest, (response) =>
            {
                if (response.success)
                {
                    Dictionary <string, string> headers = new Dictionary <string, string>();
                    headers.Add("x-auth-token", activeConfig.token);
                    cacheServerRequest.extraHeaders = headers;
                    if (cacheServerRequest.retryCount < 4)
                    {
                        SendRequest(cacheServerRequest, OnServerResponse);
                        cacheServerRequest.retryCount++;
                    }
                    else
                    {
                        LootLockerSDKAdminManager.DebugMessage("Admin token refresh failed");
                        LootLockerResponse res = new LootLockerResponse();
                        res.statusCode         = 401;
                        res.Error    = "Admin token Expired";
                        res.hasError = true;
                        OnServerResponse?.Invoke(res);
                    }
                }
                else
                {
                    LootLockerSDKAdminManager.DebugMessage("Admin token refresh failed", true);
                    LootLockerResponse res = new LootLockerResponse();
                    res.statusCode         = 401;
                    res.Error    = "Admin token Expired";
                    res.hasError = true;
                    OnServerResponse?.Invoke(res);
                }
            });
        }