Fixes broken authentication due to changes in the myq cloud api (#15755)

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
This commit is contained in:
Dan Cunningham 2023-10-14 10:05:47 -07:00 committed by Jacob Laursen
parent c8634f7e6f
commit d3609d4673

View File

@ -96,8 +96,8 @@ public class MyQAccountHandler extends BaseBridgeHandler implements AccessTokenR
* MyQ oAuth relate fields
*/
private static final String CLIENT_SECRET = "VUQ0RFhuS3lQV3EyNUJTdw==";
private static final String CLIENT_ID = "IOS_CGI_MYQ";
private static final String REDIRECT_URI = "com.myqops://ios";
private static final String CLIENT_ID = "ANDROID_CGI_MYQ";
private static final String REDIRECT_URI = "com.myqops://android";
private static final String SCOPE = "MyQ_Residential offline_access";
/*
* MyQ authentication API endpoints
@ -151,7 +151,7 @@ public class MyQAccountHandler extends BaseBridgeHandler implements AccessTokenR
username = config.username;
password = config.password;
// MyQ can get picky about blocking user agents apparently
userAgent = MyQAccountHandler.randomString(20);
userAgent = ""; // no agent string
needsLogin = true;
updateStatus(ThingStatus.UNKNOWN);
restartPolls(false);
@ -493,6 +493,9 @@ public class MyQAccountHandler extends BaseBridgeHandler implements AccessTokenR
.param("response_type", "code") //
.param("scope", SCOPE) //
.agent(userAgent).followRedirects(true);
request.header("Accept", "\"*/*\"");
request.header("Authorization",
"Basic " + Base64.getEncoder().encodeToString((CLIENT_ID + ":").getBytes()));
logger.debug("Sending {} to {}", request.getMethod(), request.getURI());
ContentResponse response = request.send();
logger.debug("Login Code {} Response {}", response.getStatus(), response.getContentAsString());