Skip to content

detect incorrect format of token #43

@Mathadon

Description

@Mathadon

When using a wrongly formatted token, e.g.

s.add("123423123123123123 123123", "123423123123123123123123")

(note the space) an error is produced.

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.flukso.net/sensor/123423123123123123%20123123/tmpo/sync?rid=0&lvl=0&bid=0

This error persists when fixing the typo since the tokens are apparently cached without checking whether the format is correct. The problem is fixed with s.remove("123423123123123123 123123"). Still, a format check would be useful. E.g.

import re
correctlyFormatted = re.match(r"^[a-z0-9]{32}$", token) is not None

should work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions