private static IRestRequest RegisterRequest(BacktoryUser registrationParams)
        {
            var request = Backtory.RestRequest("auth/users", Method.POST);

            request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId);
            request.AddJsonBody(registrationParams);
            return(request);
        }
        private IRestRequest UpdateUserRequest(BacktoryUser toBeUpdateUser)
        {
            var request = Backtory.RestRequest("auth/users/{user_id}", Method.PUT);

            request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId);
            request.AddHeader(KeyAuthorization, AuthorizationHeader());
            request.AddParameter("user_id", toBeUpdateUser.UserId, ParameterType.UrlSegment);
            request.AddJsonBody(toBeUpdateUser);
            return(request);
        }
        internal static IRestRequest NewAccessTokenRequest()
        {
            var request = Backtory.RestRequest("auth/login", Method.POST);

            request.AlwaysMultipartFormData = true;
            request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId);
            request.AddHeader(Backtory.AuthClientKeyString, BacktoryConfig.BacktoryAuthClientKey);
            request.AddHeader("X-Backtory-Authentication-Refresh", "1");
            request.AddParameter("refresh_token", BacktoryUser.GetRefreshToken(), ParameterType.GetOrPost);
            return(request);
        }
 internal static void ClearBacktoryStoredData()
 {
     currentUser = null;
     Backtory.Storage.Clear();
 }
 private static void DispatchSaveCurrentUser(BacktoryUser backtoryUser)
 {
     Backtory.Dispatch(() => { SaveAsCurrentUserInMemoryAndStorage(backtoryUser); });
 }
 private static void SaveAsCurrentUserInMemoryAndStorage(BacktoryUser user)
 {
     currentUser = user;
     Backtory.Storage.Put(KeyUsername, user.Username);
     Backtory.Storage.Put(KeyCurrentUser, Backtory.ToJson(user));
 }