API is not working with sandbox generated PATs #4021
Answered
by
frankie567
PeterWaIIace
asked this question in
Q&A
-
Is API working with sandbox generated PAT? I was trying to test it for license keys, but it seems every time I try to connect with sandbox PAT I receive 401. Cannot find anything in documentation. Test code: POLAR_TEST_TOKEN="<TOKEN_GENERATED_IN_SANDBOX>"
service = Polar(
access_token=POLAR_TEST_TOKEN,
)
res = service.license_keys.list() Error: http_res: <Response [401 Unauthorized]>
Polar caught exception: 1 validation error for Unmarshaller
body.detail
Field required [type=missing, input_value={'error': 'invalid_token'...lid for other reasons.'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/missing
Traceback (most recent call last):
[...]
res = self.service.license_keys.list()
File "~/.local/lib/python3.10/site-packages/polar_sdk/license_keys.py", line 121, in list
data = utils.unmarshal_json(http_res.text, models.UnauthorizedData)
File "~/.local/lib/python3.10/site-packages/polar_sdk/utils/serializers.py", line 120, in unmarshal_json
return unmarshal(from_json(raw), typ)
File "~/.local/lib/python3.10/site-packages/polar_sdk/utils/serializers.py", line 130, in unmarshal
m = unmarshaller(body=val)
File "~/.local/lib/python3.10/site-packages/pydantic/main.py", line 212, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Unmarshaller
body.detail
Field required [type=missing, input_value={'error': 'invalid_token'...lid for other reasons.'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/missing
|
Beta Was this translation helpful? Give feedback.
Answered by
frankie567
Sep 19, 2024
Replies: 1 comment 1 reply
-
💣 You discovered a secret! I was actually planning to add docs and announce sandbox today 😄 So, your issue here is that you need to tell the SDK to hit the sandbox server. You need to add the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: https://github.com/polarsource/polar-python/?tab=readme-ov-file#select-server-by-name