Skip to content

Adds desktop authentication flow#27

Merged
tayden merged 42 commits into
mainfrom
desktop-flow
Sep 16, 2025
Merged

Adds desktop authentication flow#27
tayden merged 42 commits into
mainfrom
desktop-flow

Conversation

@tayden

@tayden tayden commented Sep 11, 2025

Copy link
Copy Markdown
Collaborator

Adds the desktop login flow for more seamless API authorization in desktop apps. Users will no longer be required to copy and paste credentials.

This needs more work, but is functional as is.

@tayden
tayden requested a review from boshek September 11, 2025 22:18
@tayden

tayden commented Sep 11, 2025

Copy link
Copy Markdown
Collaborator Author

To do:

  • Refactoring/simplification of Client.py for easier maintainability
    • Split the desktop client out into a new DesktopClient class? Or keep things integrated?
    • Use a strategy pattern and keep the client class as a factory class to maintain backwards compatability.
  • Opt-in or opt-out of token refresh
  • Incorporate some of the quality-of-life improvements that the R client has (like saving the base url) [probably in a new PR]

@tayden tayden self-assigned this Sep 11, 2025
Implements a token refresh mechanism for the web authentication strategy.
This allows the application to obtain new access tokens using a refresh
token, improving security and user experience by reducing the need for
frequent re-authentication.
Ensures consistent timestamp generation across different parts of the authentication strategy, aligning with the original client implementation.

This resolves potential issues with credential expiry checks that could arise from inconsistent timestamp handling.
These methods need dynamic control over their return values. These are backward breaking changes, but only for private methods.
@tayden
tayden marked this pull request as ready for review September 15, 2025 15:24
@tayden

tayden commented Sep 15, 2025

Copy link
Copy Markdown
Collaborator Author

This is good to go! It's pretty slick.

  • You can select the "desktop" or "web" (default) auth flow when you initialize the class.
  • There's a initialization flag to disable use of the refresh tokens (currently, does use refresh tokens by default)
  • I also added the ability to use relative API urls (e.g. /whoami vs f"{api.root_url}/whoami").
  • Code is setup to add additional auth flows in the future if needed (e.g. a "Service" flow, perhaps?)
  • Configurable credentials file location
  • Configurable user agent identifier

@boshek boshek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great. I tried it out locally at it worked perfectly. And the code is rock solid. What a great improvement. One non-blocking thought here is whether we should start including a changelog or release notes here.

thanks for the all tests too!

Comment thread src/hakai_api/auth/desktop.py Outdated
Comment thread src/hakai_api/auth/desktop.py Outdated
Comment thread README.md
Comment thread README.md Outdated
Comment thread README.md Outdated
tayden and others added 2 commits September 16, 2025 08:47
Co-authored-by: Sam Albers <sam.albers@hakai.org>
Co-authored-by: Sam Albers <sam.albers@hakai.org>
@boshek

boshek commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

I believe this also closes #26

@tayden
tayden merged commit fc25991 into main Sep 16, 2025
20 checks passed
@tayden
tayden deleted the desktop-flow branch September 16, 2025 15:35
@boshek boshek mentioned this pull request Sep 17, 2025
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.

2 participants