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

Added support for private profiles #49

Merged
merged 7 commits into from
Mar 5, 2024

Conversation

lluni
Copy link
Contributor

@lluni lluni commented Mar 12, 2023

πŸ“‘ Description

Implements #35 by optionally using OAuth.

βœ… Checks

  • code: My pull request adheres to the code style of this project (I ran cargo fmt.)
  • docs: Added / updated (Which docs?)
  • tests: All the tests have passed (Which tests? I have tested this PR with my own private trakt profile.)

β„Ή Additional Information

This PR adds the following entries to credentials.ini:

[Trakt API]
...
enabledOAuth = false
traktClientSecret =
OAuthAccessToken =
OAuthRefreshToken =
OAuthRefreshTokenExpiresAt =
...

If the user wants to enable OAuth, it is expected that they set enabledOAuth = true and traktClientSecret = <trakt client secret>, otherwise they can be left as is. The three other fields are set programmatically.

Application flow for using OAuth for the first time:

  1. Set both aforementioned values.
  2. Log into the automatically opened trakt OAuth website.
  3. Paste the displayed OAuth code into the command line.
  4. The other tokens are generated automatically and all the following starts of discrakt do not need any interaction.

I haven't found a nice way to write the generated tokens back to credentials.ini. The straightforward way to loading the whole config, changing the token entries and writing the whole config back to credentials.ini results in "ugly" formatting. Maybe writing them to the file "manually" would be better (but somewhat annoying to implement)?
The order of the entries in credentials.ini is now kept the same when writing the OAuth tokens back to the file (4336736). The only thing left regarding "ugly" formatting is that the spaces around the equal signs are removed when writing the values back to the file, but I haven't found a fix for that.

@lluni lluni force-pushed the support-private-profiles branch from d726240 to 66a1de5 Compare March 13, 2023 00:54
@lluni
Copy link
Contributor Author

lluni commented Mar 13, 2023

For the record: I force-pushed because the previous commits didn't have semantic commit messages.

@afonsojramos
Copy link
Owner

Thanks for the PR and sorry for the late review, merging in!

@afonsojramos afonsojramos merged commit e9d6796 into afonsojramos:main Mar 5, 2024
4 checks passed
Comment on lines +6 to +8
OAuthAccessToken =
OAuthRefreshToken =
OAuthRefreshTokenExpiresAt =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these three values are fetched by the application and not set by the user, this should not live in the credentials.ini (user configuration) file but in a separate "cache" file. This would make a consistent config file across multiple machines (useful for dotfiles).

Copy link
Contributor

@sitiom sitiom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

3 participants