07-11-2023 04:16 PM
I'm developing an app, based from the smart home washer starter repo, that acts as a medium between google home and my device.
So far every command and query has been working, but when the auth token I give google expires the first request after refresh times out.
Normally:
1. "Hey Google, interact with my Device"
2. "Ok I have interacted with your device"
If the token needs to refresh:
1. "Hey Google, interact with my Device"
2. *Pauses for around 10 seconds* "I'm sorry I cannot reach your company service"
The weird thing is, logs show the refresh token function taking only 500ms, and the request still goes through to my device. The only real problem is that the google nest speaker doesn't SAY that the command was successful.
The new token is still issued to google and works fine, the initial command works fine, but the smart home response is killer as it will give the appearance of failure every day (or however long a token is valid for). Is this a common issue with token refreshing?
LOGS for token function:
DEBUG 2023-07-11T23:02:49.683957198Z Function execution took 400 ms, finished with status code: 200
Relevant Refresh Token code block
else if (grantType === "refresh_token") {
const headers = {
"Content-Type": "application/json",
};
let body = {
refreshToken: request.body.refresh_token,
};
var requestOptions = {
method: "POST",
headers: headers,
body: JSON.stringify(body),
};
await fetch(${companyloginURL}, requestOptions)
.then((res) => res.json())
.then((res) => {
if (res.status == 200) {
obj = {
token_type: "Bearer",
access_token: res.data.access_token,
expires_in: expiresIn, //1 day
};
}
})
.catch((err) => {
functions.logger.info("refreshtoken Error", err);
response.status(500);
});
}
response.status(HTTP_STATUS_OK).json(obj);
Answered! Go to the Recommended Answer.
07-17-2023 06:02 AM
07-17-2023 06:02 AM
07-23-2023 08:04 AM
#
07-31-2023 09:01 AM
Hello Sipriyadarshi. I just wanted to ping you in case you didn't see my reply. I realized that I didn't reply directly to your answer.
07-17-2023 01:33 PM - edited 07-17-2023 04:07 PM
Hello sipriyadarshi,
I have verified the following:
A) When the old access_token expires the new one issued in the "refresh token" function is the same that google gives in the subsequent repsonses.
To elaborate:
07-17-2023 04:13 PM
Additional data that may help:
When the token expiry is 10 mins, the timeout happens every time there is a refresh. However, if I change the token expiry to 5 minutes, there will be no timeout if I make a request every 5 minutes, after the token expires.
BUT if I wait 10 minutes to make a new call, the timeout still happens.
07-23-2023 08:07 AM - edited 07-23-2023 08:08 AM
#
08-28-2023 05:29 PM
I have the same issue.
When issuing a voice command after about 1 hour, ( possibly the access token has expired, and needs a new token) there is a long delay of about 5 - 10 seconds. Google Home speakers respond with "I cannot reach <name> " . Most of the time the exec command gets executed and the action happens.
I also noticed that token refresh and EXEC api calls are less than 1 second.
Have no idea what is the issue.