Skip to content

Commit

Permalink
[surepetcare] Adapt blocked user agent (#15047)
Browse files Browse the repository at this point in the history
* Adapt blocked user agent

Fixes #15046

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
  • Loading branch information
jlaur authored Jun 2, 2023
1 parent 43d3553 commit 3c1cbaa
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public class SurePetcareAPIHelper {

private final Logger logger = LoggerFactory.getLogger(SurePetcareAPIHelper.class);

private static final String API_USER_AGENT = "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";

private static final String API_URL = "https://app.api.surehub.io/api";
private static final String TOPOLOGY_URL = API_URL + "/me/start";
private static final String PET_BASE_URL = API_URL + "/pet";
Expand All @@ -78,9 +76,15 @@ public class SurePetcareAPIHelper {
private String username = "";
private String password = "";

private final String userAgent;

private @NonNullByDefault({}) HttpClient httpClient;
private SurePetcareTopology topologyCache = new SurePetcareTopology();

public SurePetcareAPIHelper() {
userAgent = "openHAB/" + org.openhab.core.OpenHAB.getVersion();
}

/**
* Sets the httpClient object to be used for API calls to Sure Petcare.
*
Expand Down Expand Up @@ -369,7 +373,7 @@ private void setConnectionHeaders(Request request) throws ProtocolException {
request.header(HttpHeader.AUTHORIZATION, "Bearer " + authenticationToken);
request.header(HttpHeader.CONNECTION, "keep-alive");
request.header(HttpHeader.CONTENT_TYPE, "application/json; utf-8");
request.header(HttpHeader.USER_AGENT, API_USER_AGENT);
request.header(HttpHeader.USER_AGENT, userAgent);
request.header(HttpHeader.REFERER, "https://surepetcare.io/");
request.header("Origin", "https://surepetcare.io");
request.header("Referer", "https://surepetcare.io");
Expand Down

0 comments on commit 3c1cbaa

Please sign in to comment.