Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper support for alternate auth accounts #807

Open
dbarnett opened this issue Oct 7, 2024 · 4 comments
Open

Proper support for alternate auth accounts #807

dbarnett opened this issue Oct 7, 2024 · 4 comments

Comments

@dbarnett
Copy link
Collaborator

dbarnett commented Oct 7, 2024

There should be a convenient way for users to switch between different authenticated accounts in gcalcli.

Currently this can be done by twiddling oauth files (see #805), but the mechanism is clunky and not very discoverable. The ideal would probably be to have a set of named auth accounts and to be able to configure --account=someaccount@domain in cli args and config files.

@dbarnett
Copy link
Collaborator Author

dbarnett commented Oct 7, 2024

Or maybe instead of separate configs per account, the config.toml structure should change to support e.g.

[accounts."account1@domain".calendars]
ignore-calendars = ["cal1", "cal2"]

?

@dbarnett
Copy link
Collaborator Author

dbarnett commented Oct 7, 2024

I hit one snag that the oauth tokens we receive don't seem to include an account name or email to identify separate accounts. It seemed like the openid and …userinfo.email scopes might help get that included (relevant OAuth docs), but I haven't quite figured out how yet, and requesting more than one scope seems to make the auth flow more complicated with checkboxes on the scopes you have to make sure to manually check.

Alternatively we could just let users manually name the accounts and store one unnamed one as "default", like:

$ gcalcli init
…
Successfully loaded credentials for account "default".

$ gcalcli init --account=work
…
Successfully loaded credentials for account "work".

@dbarnett
Copy link
Collaborator Author

dbarnett commented Oct 7, 2024

K for reference, I was able to successfully fetch account ID / email using their recommended way from google_auth_oauthlib docs:

flow = InstalledAppFlow.from_client_config(
    …
    scopes=[
        "openid",
        "https://www.googleapis.com/auth/userinfo.email",
        "https://www.googleapis.com/auth/calendar",
    ],
)
session = flow.authorized_session()
profile_info = session.get(
    'https://www.googleapis.com/userinfo/v2/me').json()

but I can't figure out how to get it to require multiple scopes like that w/o the annoying checkboxes and am leaning towards just letting users explicitly assign names to the accounts like gcalcli init --account=someaccount2.

@ahughes03
Copy link

I like the idea of using an --account flag to define the location of the oauth/config files. Previously, I ran two commands in my conky config to see calendars from two separate accounts. An --account flag should allow my use case to work again, provided the flag works with other commands like list, agenda, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants