pyronear / pyro-api

Alert Management API for wildfire prevention, detection & monitoring. Built with FastAPI & PostgreSQL
Apache License 2.0
21 stars 9 forks source link

[client][Retrieve Token] Issues passing creds with Content Type "application/x-www-form-urlencoded" #214

Closed fe51 closed 2 years ago

fe51 commented 2 years ago

Hi there,

Using the api client, I have an issue when retrieving token ( in the frame of the installation of the newest test tower in Ardeche)

With correct creds (tested at https://api.pyronear.org/docs ), it basically works with some creds, and not with others !

At first, I thought it might be due to the encoding of the characters, as "application/x-www-form-urlencoded" as Content type is not recommended to send text with non ASCII characters, in the request headers.

Hence, switching from request with application/x-www-form-urlencoded to a "classic" post request with a json data, solves the issue. However I realise that this solution is fortuitous because creds tested do not contain non-ASCII characters 🤣

So, to be pragmatic, why using content type application/x-www-form-urlencoded in the first place to retrieve token ? Is there any specific reason ? Otherwise, this PR #215 could be useful to avoid the problem mentioned above

happy to discuss it !

If anyone has an explanation as to why this doesn't work, I'm interested (text encoding then decoding causing issues?)

fe51 commented 2 years ago

@pyronear/back-end

fe51 commented 2 years ago

@MateoLostanlen @Akilditu

frgfm commented 2 years ago

Oh now I understand: when I generate the creds for this, there were indeed perhaps rarer characters. So the encoding might be different from the swagger :+1:

Let me take a look at the PR!