Skip to content

Commit

Permalink
fix parking position refresh token
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Nov 6, 2023
1 parent be9be02 commit 4dfcb64
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ class VwWeconnect extends utils.Adapter {
}
if (this.config.type === "skodae") {
const parsedParameters = qs.parse(hash);
this.config.atoken = parsedParameters.access_token;
// this.config.atoken = parsedParameters.access_token;
let systemId = "TECHNICAL";
if (this.clientId === "7f045eee-7003-4379-9968-9355ed2adb06%40apps_vw-dilab_com") {
systemId = "CONNECT";
Expand All @@ -1171,7 +1171,7 @@ class VwWeconnect extends utils.Adapter {
});
headers = {
accept: "*/*",
authorization: "Bearer " + parsedParameters.id_token,
// authorization: "Bearer " + parsedParameters.id_token,
"content-type": "application/json",
"user-agent": this.useragent,
"accept-language": "de-de",
Expand Down Expand Up @@ -1357,9 +1357,9 @@ class VwWeconnect extends utils.Adapter {
return;
}

if (this.config.atoken && this.clientId != "7f045eee-7003-4379-9968-9355ed2adb06%40apps_vw-dilab_com") {
this.secondAccessToken = this.config.atoken;
this.secondRefreshToken = this.config.rtoken;
if (this.clientId != "7f045eee-7003-4379-9968-9355ed2adb06%40apps_vw-dilab_com") {
this.secondAccessToken = tokens.accessToken;
this.secondRefreshToken = tokens.refreshToken;
}
if (Object.keys(tokens).length > 0) {
this.config.atoken = tokens.access_token || tokens.accessToken;
Expand All @@ -1385,7 +1385,7 @@ class VwWeconnect extends utils.Adapter {
this.refreshToken().catch(() => {
this.log.error("Refresh Token was not successful");
});
if (this.secondAccessToken && !this.secondRefreshToken === "blocked") {
if (this.secondAccessToken) {
this.refreshToken(null, true).catch(() => {
this.log.error("Refresh Second Token was not successful");
});
Expand Down Expand Up @@ -3045,6 +3045,7 @@ class VwWeconnect extends utils.Adapter {
}
})
.catch((error) => {
this.log.debug(status.path);
this.log.debug(error);
error.response && this.log.debug(JSON.stringify(error.response.data));

Expand All @@ -3063,11 +3064,7 @@ class VwWeconnect extends utils.Adapter {
}
this.log.error(JSON.stringify(error.response.data));
}
// if (status.path === "position/vehicles") {
// this.log.warn("Parking position failed. Blocked until restart");
// this.secondAccessToken = "blocked";
// return;
// }

this.log.error(error);
this.log.error(url);
});
Expand Down

0 comments on commit 4dfcb64

Please sign in to comment.