rtv icon indicating copy to clipboard operation
rtv copied to clipboard

[Feature Request] multi account

Open blackdev1l opened this issue 7 years ago • 10 comments

Hi, is there any chance to get multi account ? I'd like to contribute to this if it's accepted

blackdev1l avatar Jun 01 '17 08:06 blackdev1l

Hi, could you explain what you mean by multi account? I'm not familiar with that term.

michael-lazar avatar Jun 01 '17 12:06 michael-lazar

I mean the feature to use multiple account in the same context. You can switch to other accounts and have all the subreddits and such shown without log out and log in.

I'd add in the log out phase the possibility to add another account (using the same oauth's methods) , then you can choose to switch between accounts.

blackdev1l avatar Jun 01 '17 14:06 blackdev1l

Ok I understand now, you want to be able to switch between multiple oauth credentials instead of overwriting the refresh-token file every time you switch accounts. I'm pretty sure this has been requested by somebody else also but I can't find the issue for it.

I think that it would be a fine feature to add, but we have to be careful with adding additional complexity to the UI and the codebase for a feature that I don't think that the majority of users will care about. If you want a quick solution, the easiest thing to do would to be to make the refresh-token file configurable through the command line. Then you could define aliases like:

alias rtv_user1 = "rtv --refresh-token=~/.config/rtv/refresh-token-user1"
alias rtv_user2 = "rtv --refresh-token=~/.config/rtv/refresh-token-user2"

Or you could take it one step further and infer which token to use from the user name

rtv --user user1
rtv --user user2

The above wouldn't allow you to switch accounts without restarting rtv though. Doing that would be a bit more involved, but you're welcome to choose which method that you want to use if you're interested in contributing. Let me know if you have any questions or if you would like feedback on your implementation ideas.

michael-lazar avatar Jun 01 '17 17:06 michael-lazar

What would you think about an additional command during logout to give to the user the option to log in with another account?

Thank you for the long answer by the way

blackdev1l avatar Jun 02 '17 17:06 blackdev1l

i was thinking to add this command without cluttering the interface with another shortcut, but i can't think something elegant enough other than put an additional choice in the log out menu, but then the "log out" command would be something more like "log out / swtich account"

Another way would be add another shortcut to the log in command (U maybe?) with the add another account, maybe not shown in the CLI but inside the ? page. with the same command you could switch between accounts.

I'm learning the codebase right now but i'm not familiar with the python way to dealing with objects. I have a ruby background and i hope it will help :)

blackdev1l avatar Jun 02 '17 18:06 blackdev1l

I'm also interested in this feature. I have one main account that has all my subscriptions, multi-reddits, but I often like to make comments on throwaways for privacy. While ideally I'd like to be able to swap accounts in-app (or even just make a comment as a different account), that's more work than I have time for. Having to restart rtv with a command line flag is an acceptable solution. Better than having to oauth each time.

If you want a quick solution, the easiest thing to do would to be to make the refresh-token file configurable through the command line. Then you could define aliases like:

@michael-lazar, any pointers on how I'd do this? Files to change, maybe a preferred approach? Storing the config state in the filesystem should be pretty straightforward, but I'm wondering if I'll have to modify a bunch of files or if this is pretty low-touch. Also if you have a change in perspective to the approach you suggested before, just let me know. I want to make sure my implementation fits the rtv way.

If it's relatively quick I should be able to find the time to do it and push up a pull request.

Lastly - love the project! Thanks for working on it. 🥇

acoard avatar Sep 27 '17 19:09 acoard

Hey, thanks for offering to contribute 👍 I still think that this approach is still probably the simplest way to go about it.

Most everything that you need should be in config.py. You will need to add a parser argument for the new --refresh-token parameter. Probably you will want to remove the Config(..., token_file=TOKEN, ...) argument from the constructor, and instead have it loaded from the user's configuration settings. One way to go about it might be to switch config.refresh_token to a property, something like:

class Config(object):
    ...

    @propery
    def refresh_token(self):
        return self.config.get('refresh_token', TOKEN)

Also, check out tests/test_config.py to make sure that your new paramater is fully tested. It should be pretty straightforward.

michael-lazar avatar Sep 27 '17 20:09 michael-lazar

Coming to this strictly from a user's point of view, I suggest that rtv could use the feature that you login to a specific user with U <user1> and switch users with U <user2> while logged in. u without usernames would retain current functionality.

I am surprised that rtv lacks this at the moment. On the reddit enhancement suite for Chrome/Firefox, you click on the user icon to switch users, reddit reloads, but otherwise you are still in the same subreddit.

It seems to be a highly popular feature as well, judging from the discussions.

If you are in doubt about the cost / benefit of such an improvement, maybe it's easier to implement a --save position option which returns you to where you have been, so a restart of rtv wouldn't be a problem. This could be coupled then with --refresh-token as outlined by you above.

The saved position is the most important improvement. Changing users could be done with a bash script rtvu if necessary:

#!/bin/bash

### usage: rtvu <username> [rtv options]  ###

# Before use: log into reddit with rtv, quit and do 
# cp ~/.local/share/rtv/refresh-token ~/.config/rtv/refresh-token-<username> *for each user*

cp ~/.config/rtv/refresh-token-$1 ~/.local/share/rtv/refresh-token
shift
rtv "$@"

emk2203 avatar Mar 01 '18 09:03 emk2203

+1 for this feature, and this implemntation. I'd /love/ to be able to switch accounts on the fly but keep the focused content as is.

fullstopslash avatar Mar 05 '18 17:03 fullstopslash

For privacy, this needs to happen in a way that is Tor-aware and supports stream isolation. That ultimately means that every account should have a proxy field, so that users can ensure that every account has a different exit node (thus different IP address).

It also means the accounts should not login all at once simultaneously. RTV should use a random delay for each account, the range of which is user specified.

So an account config might be like this:

userid pass proxy rule delay (seconds)
bob bob's cat's name socks4a://127.0.0.1:9051 15-90
alice bob's other cat's name socks4a://127.0.0.1:9052 5-20

(edit) Regardless of multiple account support, it's a bit annoying to have to manually login through a GUI. I think people have a natural expectation that a tool like rtv would handle logins. So multiple account support would ideally automate logins and thus be useful to people who even just have one account.

ghost avatar Mar 28 '19 20:03 ghost