-
Notifications
You must be signed in to change notification settings - Fork 22
Expose api key validation #491
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
base: main
Are you sure you want to change the base?
Conversation
|
@mattgd - I'd like to get this contribution in, but I'm unsure of the next steps. The PR template tells me link a PR to corresponding docs, however, searching for |
nholden
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Hey, @denizs, thanks for this contribution!
I pulled this PR down and tried getting it working with an example app locally, and I bumped into some issues. First, I saw a ModuleNotFoundError: No module named 'workos.types.api_keys', which Claude Code suggests could reflect a naming conflict between a type and a class. Second, I saw that the API endpoint wasn't being called correctly, as I noted inline.
I'd like to get this contribution in, but I'm unsure of the next steps.
Could you get this change working in an app on your machine? After you've done that, please ping me for another review.
| response = self._http_client.request( | ||
| "api_keys/validate", | ||
| method=REQUEST_METHOD_POST, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validate API key endpoint lives at /api_keys/validations (not /api_keys/validate), and it requires that the caller pass in a value.
|
Hey @nholden sorry for that very unpleasant review. I should've mentioned the PR is by far not ready for review and that I'm primarily wondering what to do about the following sentence in the PR template:
It sounded like I had to first create another PR somewhere else before getting this one reviewed. I've cleaned up the AI slop and can confirm it's working on my machine ™️. I've used the API key widget to issue an API key for our application and then successfully validated it: |
Greptile OverviewGreptile SummaryThis PR adds API key validation functionality to the workos-python SDK, allowing developers to programmatically validate API keys. Key Changes:
Implementation Quality:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client as SDK Client
participant ApiKeys as ApiKeys Module
participant HTTP as HTTP Client
participant API as WorkOS API
Client->>ApiKeys: validate_api_key(value="sk_...")
ApiKeys->>HTTP: request(path="api_keys/validations", method=POST, json={value: "sk_..."})
HTTP->>API: POST /api_keys/validations
alt Valid API Key
API-->>HTTP: 200 OK {api_key: {...}}
HTTP-->>ApiKeys: response_json
ApiKeys->>ApiKeys: ApiKey.model_validate(response["api_key"])
ApiKeys-->>Client: ApiKey object
else Invalid API Key
API-->>HTTP: 401 Unauthorized
HTTP->>HTTP: raise AuthenticationException
HTTP-->>ApiKeys: AuthenticationException
ApiKeys-->>Client: AuthenticationException
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9 files reviewed, no comments
Description
Documentation
Once a new version is released, one could update the code examples that are currently limited to
authkit-nextjsandexpress.If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.