From 6607b5125d2c5c3aadb02bad6258e3c8d4abc080 Mon Sep 17 00:00:00 2001 From: MiGoller <1272642+MiGoller@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:15:44 +0100 Subject: [PATCH] Updated headers and url for API requests --- README.md | 5 +++++ lib/life360CloudConnector.js | 32 ++++++++++++++++++++++---------- package.json | 3 +++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 70763f2..62a3a92 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,11 @@ Feel free to modify the default timespan of 60 seconds for the polling interval. Placeholder for the next version (at the beginning of the line): ### **WORK IN PROGRESS** --> + +### **WORK IN PROGRESS** + +- (MiGoller) Fix for issue [#83 Verbindungsproblem 20.12.23 Check your credentials!](https://github.com/MiGoller/ioBroker.life360/issues/83) . + ### 0.2.21 (2023-08-01) - (MiGoller) Fix for issue [#76: Die Verbindung wurde hergestellt, die Authentifizierung konnte jedoch nicht durchgeführt werden. Überprüfen Sie Ihre Anmeldedaten!](https://github.com/MiGoller/ioBroker.life360/issues/76) diff --git a/lib/life360CloudConnector.js b/lib/life360CloudConnector.js index 176eac7..384510d 100644 --- a/lib/life360CloudConnector.js +++ b/lib/life360CloudConnector.js @@ -21,9 +21,9 @@ const myLogger = new iobHelpers.IobLogger(adapter); /** * Hard-coded "CLIENT_SECRET": Has to be identified and verified after Life360 publishes a new version of the mobile app! */ -const LIFE360_CLIENT_SECRET = "YnJ1czR0ZXZhcHV0UmVadWNydUJSVXdVYnJFTUVDN1VYZTJlUEhhYjpSdUt1cHJBQ3JhbWVzV1UydVRyZVF1bXVtYTdhemFtQQ=="; -const DEFAULT_CLIENT_VERSION = "22.6.0.532"; -const DEFAULT_USER_AGENT = "SafetyMapKoko"; +const LIFE360_CLIENT_SECRET = "Y2F0aGFwYWNyQVBoZUtVc3RlOGV2ZXZldnVjSGFmZVRydVl1ZnJhYzpkOEM5ZVlVdkE2dUZ1YnJ1SmVnZXRyZVZ1dFJlQ1JVWQ=="; +const DEFAULT_CLIENT_VERSION = "23.49.0 android"; +const DEFAULT_USER_AGENT = "com.life360.android.safetymapd/KOKO"; /** * The Life360 API URIs. @@ -31,7 +31,7 @@ const DEFAULT_USER_AGENT = "SafetyMapKoko"; * - circles URL */ const LIFE360_URL = { - login: "https://api-cloudfront.life360.com/v3/oauth2/token.json", + login: "https://api-cloudfront.life360.com/v3/oauth2/token", circles: "https://api-cloudfront.life360.com/v3/circles" }; @@ -205,7 +205,9 @@ exports.connectLife360 = function(username, password, phone, countryCode) { "Authorization": `Basic ${LIFE360_CLIENT_SECRET}`, "Content-Type" : "application/json", "X-Device-ID": deviceId, - "User-Agent": `${userAgent}/${clientVersion}/${deviceId}` + "User-Agent": `${userAgent}/${clientVersion}/${deviceId}`, + "Accept": "application/json", + "Cache-Control": "no-cache", }, json: true }; @@ -327,7 +329,9 @@ exports.getCircles = function(auth_in) { "Authorization": `${auth_in.token_type} ${auth_in.access_token}`, "Content-Type" : "application/json", "X-Device-ID": deviceId, - "User-Agent": `${userAgent}/${clientVersion}/${deviceId}` + "User-Agent": `${userAgent}/${clientVersion}/${deviceId}`, + "Accept": "application/json", + "Cache-Control": "no-cache", }, json: true }; @@ -371,7 +375,9 @@ exports.getCircleById = function(auth_in, circleId) { "Authorization": `${auth_in.token_type} ${auth_in.access_token}`, "Content-Type" : "application/json", "X-Device-ID": deviceId, - "User-Agent": `${userAgent}/${clientVersion}/${deviceId}` + "User-Agent": `${userAgent}/${clientVersion}/${deviceId}`, + "Accept": "application/json", + "Cache-Control": "no-cache", }, json: true }; @@ -582,7 +588,9 @@ exports.getCirclesAsync = async function(auth_in) { "Authorization": `${auth_in.token_type} ${auth_in.access_token}`, "Content-Type" : "application/json", "X-Device-ID": deviceId, - "User-Agent": `${userAgent}/${clientVersion}/${deviceId}` + "User-Agent": `${userAgent}/${clientVersion}/${deviceId}`, + "Accept": "application/json", + "Cache-Control": "no-cache", }, json: true }; @@ -640,7 +648,9 @@ exports.getCircleMembersAsync = async function(auth_in, circleId) { "Authorization": `${auth_in.token_type} ${auth_in.access_token}`, "Content-Type" : "application/json", "X-Device-ID": deviceId, - "User-Agent": `${userAgent}/${clientVersion}/${deviceId}` + "User-Agent": `${userAgent}/${clientVersion}/${deviceId}`, + "Accept": "application/json", + "Cache-Control": "no-cache", }, json: true }; @@ -698,7 +708,9 @@ exports.getCirclePlacesAsync = async function(auth_in, circleId) { "Authorization": `${auth_in.token_type} ${auth_in.access_token}`, "Content-Type" : "application/json", "X-Device-ID": deviceId, - "User-Agent": `${userAgent}/${clientVersion}/${deviceId}` + "User-Agent": `${userAgent}/${clientVersion}/${deviceId}`, + "Accept": "application/json", + "Cache-Control": "no-cache", }, json: true }; diff --git a/package.json b/package.json index 4f03257..6540e8d 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,9 @@ "lint": "eslint", "debug": "nodemon --inspect-brk ./main.js --debug 0", "dev-server": "dev-server", + "dev-server:watch": "dev-server watch default", + "dev-server:debug": "dev-server debug default", + "dev-server:upload": "dev-server upload default", "release": "release-script" }, "bugs": {