Repository navigation
Conversation
Add an "API token scopes" section to the README that maps every SDK method to the endpoint it calls and the scopes that endpoint checks, matching the per-endpoint scopes in the public API reference. It also explains how a 401 or 403 surfaces: a missing scope raises APIAccessDenied with status_code 403 and the server's "Insufficient permissions" message, and 403s with more specific messages raise APIInsufficientPermissions, APIOrganizationNotAllowed or APIInsufficientQuota, all subclasses of APIFailure. Methods whose endpoint the reference does not list are marked as such rather than given a guessed scope.
PR SummaryLow Risk Overview The Documentation only — no SDK or release artifact changes. Reviewed by Cursor Bugbot for commit 28e78d7. Configure here. |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 28e78d7. Configure here.
Adds an "API token scopes" section to
README.rstso callers can provision a token for the methods they use, without trial and error against 403s.securityrequirements in the API reference. When an endpoint lists several scopes, all of them are required.fullscans.finalize_tier1()anduploadmanifests.upload_manifest_files()call endpoints the reference doesn't list. Both checkfull-scans:create.APIAccessDeniedwithstatus_code403 and the server'sInsufficient permissionsmessage. Every method raises rather than returning{}, becausedo_request()raises before the method sees the response. CatchingAPIFailurecovers every case.tokenparameter under "Initializing the module" links to the new section.Rows marked "not in the API reference" are deprecated report-era endpoints, plus
settings.integration_events(), which calls a path with noGETroute. #131 fixes that method. Whichever PR merges second should update its row toGET orgs/{org_slug}/settings/integrations/{integration_id}/events→integration:listand drop it from the "not in the API reference" note.Some scopes don't match the method name. These are called out in the README:
analytics.get_org()andanalytics.get_repo()checkreport:write.apitokens.update()checksapi-tokens:create.labels.setting.delete()checksrepo-label:update.export.*_bom()methods checkreport:read.README only, so no version bump.
version-checkenforces a bump only for changes undersocketdev/,pyproject.tomloruv.lock. The README renders cleanly withreadme_renderer, which is whattwine checkuses.Questions this answers
GET organizations,GET report/supportedandPOST license-metadatacheck no scope, so any valid token works.export.cdx_bom()and the other exports checkreport:read. The manifest upload andfinalize_tier1()checkfull-scans:create.APIAccessDeniedwithstatus_code403, not a bareAPIFailure. socket-python-cli mistakes a scope gap for "repository does not exist" because its lookup catches everyAPIFailure. That's a CLI fix, not an SDK one. Recent API responses also name the required scopes inerror.details.requiredScopes, which the SDK leaves out of the exception message. Surfacing them would be a small follow-up.Not in this PR
The Socket Python SDK page on docs.socket.dev still says nothing about scopes, and doesn't cover
diffscans. This PR covers the README, which is what PyPI shows. The docs-site page needs its own change in SocketDev/docs.Related PRs
Public Changelog
Documented the API token scope each SDK method needs.
Fixes: CE-462
Refs: CE-384