Skip to content

API is not working with sandbox generated PATs  #4020

@PeterWaIIace

Description

@PeterWaIIace

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions