apache / apache/iggy

Python SDK: return identity details from password and PAT login

Open
#4,167 0 comments 0 reactions 0 assignees Claimed by @Mukezh View on GitHub
good first issue python
Dominant language
Rust
Stars
4.9k
Forks
432
Avg merge
2d 10h
Merged PRs (30d)
173

Description

### Description

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

```rust
async fn login_user(
&self,
username: &str,
password: &str,
) -> Result;

async fn login_with_personal_access_token(
&self,
token: &str,
) -> Result;
```

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

- [x] I think this could be a good first issue for a new contributor

Contributor guide

Open the contributing guide

Research direction

Start with the existing wrapper pattern in foreign/python/src/user.rs and registration in foreign/python/src/lib.rs, then trace how login_user() currently handles its returned value. Update the Python interface and regenerate foreign/python/apache_iggy.pyi; done means both login methods return the exposed identity and token fields without leaking tokens through repr or diagnostics. Add the requested TCP, HTTP, and PAT login tests, including transport-specific access_token values.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
api, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.