Skip to content
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

detect incorrect format of token #43

Open
Mathadon opened this issue Sep 12, 2019 · 0 comments
Open

detect incorrect format of token #43

Mathadon opened this issue Sep 12, 2019 · 0 comments

Comments

@Mathadon
Copy link

Mathadon commented Sep 12, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant