Skip to content

Conversation

@edif2008
Copy link
Member

@edif2008 edif2008 commented Nov 6, 2025

📋 Summary

This PR adjust the behavior of the SDK in the following scenario:
A program running the SDK initializes a new client that authenticates via the Desktop app. After the client is initialized, the Desktop app gets locked. User will be re-prompted to authorize the SDK. However, after the confirmation, any operation will now fail since the session no longer exists.

🤔 Thought process

Currently, the approach is to catch the new error thrown by the SDK in this scenario: DesktopSessionExpiredException. If received, the client will do the following:

  1. Initialize a new client.
  2. Replace the old one with the new one.
  3. Retry the operation.

This class stores the client ID, the core used for making requests and the client config. This Inner client is capable of overriding its client id in case the desktop session expires due to the app getting locked.
@edif2008 edif2008 requested a review from AndyTitu November 6, 2025 15:39
The new exception added now matches the naming convention for typed errors
Copy link
Member

@Marton6 Marton6 left a comment

Choose a reason for hiding this comment

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

One issue I ran into while testing is that if the desktop app is locked before the client is released, release_client will cause a prompt to show up and will block until the prompt is approved / denied.

You can reproduce this easily by running a script that authenticates a client, sleeps, then you can manually lock the desktop app and cancel the script by hitting command / ctrl + C twice. You'll be prompted again and you'll see the behavior I described above.

The DesktopSessionExpiredException should not really be returned when we're trying to release a client, since if the desktop app has already cleaned up the client and its session, calling release_client should just be a no-op.

@edif2008
Copy link
Member Author

One issue I ran into while testing is that if the desktop app is locked before the client is released, release_client will cause a prompt to show up and will block until the prompt is approved / denied.

You can reproduce this easily by running a script that authenticates a client, sleeps, then you can manually lock the desktop app and cancel the script by hitting command / ctrl + C twice. You'll be prompted again and you'll see the behavior I described above.

The DesktopSessionExpiredException should not really be returned when we're trying to release a client, since if the desktop app has already cleaned up the client and its session, calling release_client should just be a no-op.

Thanks for pointing this out. This will be addressed on the Desktop app side. Therefore, this doesn't block this PR from getting merged.

@edif2008 edif2008 requested a review from Marton6 November 18, 2025 13:11
@edif2008 edif2008 merged commit f6bdb6b into sdks-for-desktop-integrations Nov 18, 2025
18 checks passed
@edif2008 edif2008 deleted the eddy/reauth-sdk-when-app-locked branch November 18, 2025 13:36
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