Skip to content

Python SDK: return identity details from password and PAT login #4167

Description

@jiengup

Description

The Rust SDK returns IdentityInfo from both username/password login and personal access token login:

async fn login_user(
    &self,
    username: &str,
    password: &str,
) -> Result<IdentityInfo, IggyError>;

async fn login_with_personal_access_token(
    &self,
    token: &str,
) -> Result<IdentityInfo, IggyError>;

The Python SDK currently discards the value returned by login_user() and has no manual login_with_personal_access_token() method. Python callers therefore cannot obtain the authenticated user ID or the access token information returned by HTTP login.

This covers B10 and B12 of the Python SDK parity work tracked in #3893.

Affected area / component

Python SDK

Proposed solution

  • Add Python wrappers for IdentityInfo and TokenInfo, following the existing wrapper pattern in foreign/python/src/user.rs.
  • Expose:
    • IdentityInfo.user_id
    • IdentityInfo.access_token: TokenInfo | None
    • TokenInfo.token
    • TokenInfo.expiry
  • Register the new classes in foreign/python/src/lib.rs.
  • Change login_user() to return IdentityInfo instead of discarding it.
  • Add login_with_personal_access_token() and return the same IdentityInfo wrapper.
  • Avoid exposing token values through repr() or diagnostic output.
  • Regenerate foreign/python/apache_iggy.pyi.
  • Add tests for username/password login over TCP and HTTP, including the transport-specific access_token value.
  • Add a successful PAT login test using a token minted out of band by the test setup, so this issue does not depend on exposing the PAT creation API.

Creating, listing, and deleting personal access tokens remain outside this issue.

Alternatives considered

Return only the numeric user ID. This would continue to discard the HTTP access-token details present in the Rust API.

Contribution

  • I'm willing to submit a pull request to implement this feature

Good first issue

  • I think this could be a good first issue for a new contributor

Activity

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

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomerspythonPull requests that update Python code

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions