openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.59k forks source link

[surepetcare] Login failure due to rejected HTTP user agent #15046

Closed jlaur closed 1 year ago

jlaur commented 1 year ago

Reported in the forum: https://community.openhab.org/t/sure-petcare-binding-login-failure-due-to-rejected-http-user-agent/146992

Works - HTTP code 200:

curl -v -X POST -H 'Content-Type: application/json' -d '{"email_address":"<USERNAME>","password":"<PASSWORD>","device_id":"<ANYRANDOMSTRING>"}'  -A 'Mozilla/5.0 (Linux; Android 7.0; SM-G930F Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.37' https://app.api.surehub.io/api/auth/login

Fails - HTTP code 403:

curl -v -X POST -H 'Content-Type: application/json' -d '{"email_address":"<USERNAME>","password":"<PASSWORD>","device_id":"<ANYRANDOMSTRING>"}'  -A 'Mozilla/5.0 (Linux; Android 7.0; SM-G930F Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.36' https://app.api.surehub.io/api/auth/login

Expected Behavior

Binding should be able to login and communicate with the service.

Current Behavior

Service returns HTTP code 403.

Possible Solution

Change user agent here: https://github.com/openhab/openhab-addons/blob/43d35538d5395dbe20929bd26145216d25593171/bundles/org.openhab.binding.surepetcare/src/main/java/org/openhab/binding/surepetcare/internal/SurePetcareAPIHelper.java#L66

Your Environment

openHAB 3.4

openhab-bot commented 1 year ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/sure-petcare-binding-login-failure-due-to-rejected-http-user-agent/146992/4