Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-myuplink-test-oauth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ftw": patch
---

Start the MyUplink OAuth connection flow when Test connection is used before authorization, instead of running a probe that cannot succeed without a refresh token.
20 changes: 20 additions & 0 deletions web/settings/tabs/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,26 @@
ctx.captureCurrentTab();
var driver = config.drivers && config.drivers[dIdx];
if (!driver) return;

// Authorization-code drivers such as MyUplink cannot be probed until
// the one-time OAuth consent has produced a refresh token. Treat
// "Test connection" as the next setup action instead of running a
// probe that is guaranteed to fail: start the existing Connect flow.
var oauthConnectBtn = bodyEl.querySelector('.myuplink-connect-btn[data-driver-idx="' + dIdx + '"]');
var refreshToken = driver.config && driver.config.refresh_token;
if (oauthConnectBtn && (typeof refreshToken !== "string" || refreshToken === "")) {
if (statusEl) {
statusEl.textContent = "Authorization required";
statusEl.className = "driver-test-status";
}
if (outputEl) {
outputEl.hidden = false;
outputEl.innerHTML = '<div class="driver-test-empty">Connect to MyUplink and sign in before the connection can be tested.</div>';
}
oauthConnectBtn.click();
return;
}

if (statusEl) {
statusEl.textContent = "Testing...";
statusEl.className = "driver-test-status";
Expand Down
Loading