[solved] How to add bearer token in the messages sended from dongle to the back end

#1

Hi,

  • i changed my own configuration to point to my own backend and not the backend of autopi.
  • i found that the messages are sended to http://url/logbook/storage
  • i found that the messages are in POST with this kind of format :
    { "@ts": "2019-05-31T13:57:10.483508", "value": 2304.0, "unit": "revolutions_per_minute", "@t": "obd.rpm" }, { "state": "overcharging", "voltage": 16.1, "@t": "obd.bat", "level": 100, "@ts": "2019-05-31T13:57:11.558116" }, { "@ts": "2019-05-31T13:57:11.706978", "value": 2297.0, "unit": "revolutions_per_minute", "@t": "obd.rpm" }, { "state": "overcharging", "voltage": 16.0, "@t": "obd.bat", "level": 100, "@ts": "2019-05-31T13:57:12.768266" }, { "@ts": "2019-05-31T13:57:12.910753", "value": 2304.0, "unit": "revolutions_per_minute", "@t": "obd.rpm" }, { "utc": "13:57:13", "@t": "track.pos", "sog": 108.1, "loc": { "lat": 48.61828, "lon": 6.27496 }, "@ts": "2019-05-31T13:57:13.718604", "nsat": 8, "cog": 283.51, "alt": 233.0 }
  • I found that the headers are :
    Accept:/
    User-Agent:python-requests/2.12.4
    X-Forwarded-Proto:http
    X-Country-Code:FR
    Host:myhost@gandi
    Gandi-Rp:SomeNumbers
    Accept-Encoding:gzip
    X-Forwarded-For:clientIp

I was thinking that you will passing some kind of token with the bearer header, but i get nothing… How do you make the auth of the dongle with the cloud, and is it possible to pass the token set in the settings/configuration part of cloud.autopi.io and to send it to the backend with the bearer (or other) header? I set it in the cloud setting of my dongle, but it looks like the token header is not sended by the dongle, but i dont understand why.
Finally, in the core repo, where is the implementation of that send? I would like to try to add my header manually but didnt found the method…

Have a good day.
Ben

#2

Solved with that :
.htaccess
RewriteEngine On
RewriteRule .* - [e=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

That’s allowing to get the token. Dont know why but without that the authorization was not present in the header.