Beispiel #1
0
        internal AuthenticationResult AuthenticationRefresh()
        {
            string response = AuthenticationControl.Refresh(LauncherProfilesControl.AccessToken, LauncherProfilesControl.ClientToken, "", "");

            AuthenticationResult authenticationResult = CheckForErrors(response);

            if (authenticationResult == AuthenticationResult.Success)
            {
                RootRefreshRequestResponse responseJson = null;

                try
                {
                    responseJson = JsonConvert.DeserializeObject <RootRefreshRequestResponse>(response);
                }
                catch
                { }

                if (responseJson != null && responseJson.selectedProfile != null && !string.IsNullOrWhiteSpace(responseJson.accessToken) &&
                    !string.IsNullOrWhiteSpace(responseJson.clientToken) && !string.IsNullOrWhiteSpace(responseJson.selectedProfile.name))
                {
                    LauncherProfilesControl.DisplayName = responseJson.selectedProfile.name;
                    LauncherProfilesControl.UserId      = responseJson.selectedProfile.id;
                    LauncherProfilesControl.ClientToken = responseJson.clientToken;
                    LauncherProfilesControl.AccessToken = responseJson.accessToken;
                    LauncherProfilesControl.UUID        = responseJson.clientToken;
                }
                else
                {
                    authenticationResult = AuthenticationResult.UnknownError;
                }
            }

            return(authenticationResult);
        }
        public static string Refresh(string accessToken, string clientToken, string id, string name)
        {
            RootRefreshRequestResponse jsonRequestData = new RootRefreshRequestResponse();
            SelectedProfileRefresh     profile         = new SelectedProfileRefresh();

            if (!string.IsNullOrWhiteSpace(id))
            {
                profile.id = id;
            }

            if (!string.IsNullOrWhiteSpace(name))
            {
                profile.name = name;
            }

            jsonRequestData.accessToken     = accessToken;
            jsonRequestData.clientToken     = clientToken;
            jsonRequestData.selectedProfile = profile;
            jsonRequestData.requestUser     = false;

            return(MakeRequest(JsonConvert.SerializeObject(jsonRequestData), Constants.URL_REFRESH));
        }