Add device code oauth handling
parent
7e8c2c3fcf
commit
0f73e54830
|
|
@ -57,7 +57,7 @@ Page {
|
||||||
property int pairRequestId: 0
|
property int pairRequestId: 0
|
||||||
property var pairingTransactionId: null
|
property var pairingTransactionId: null
|
||||||
property int addRequestId: 0
|
property int addRequestId: 0
|
||||||
property var name: ""
|
property string name: ""
|
||||||
property var params: []
|
property var params: []
|
||||||
|
|
||||||
function pairThing() {
|
function pairThing() {
|
||||||
|
|
@ -558,14 +558,25 @@ Page {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
url: oAuthPage.oAuthUrl
|
url: oAuthPage.oAuthUrl
|
||||||
|
|
||||||
onUrlChanged: {
|
function finishProcess(url) {
|
||||||
print("OAUTH URL changed", url)
|
print("Confirm pairing")
|
||||||
if (url.toString().indexOf("https://127.0.0.1") == 0) {
|
|
||||||
print("Redirect URL detected!");
|
|
||||||
engine.thingManager.confirmPairing(d.pairingTransactionId, url)
|
engine.thingManager.confirmPairing(d.pairingTransactionId, url)
|
||||||
busyIndicator.running = true
|
busyIndicator.running = true
|
||||||
oAuthWebView.visible = false
|
oAuthWebView.visible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUrlChanged: {
|
||||||
|
print("OAUTH URL changed", url)
|
||||||
|
if (url.toString().indexOf("https://127.0.0.1") == 0) {
|
||||||
|
print("Redirect URL detected!")
|
||||||
|
finishProcess(url)
|
||||||
|
} else if (url.toString().indexOf("device-complete") >= 0) {
|
||||||
|
// Unfortunatly device code authentication does not support redirect URLs like tado,
|
||||||
|
// yet this hack does work for this case when the authentication has been completed.
|
||||||
|
// The alternative would be a finished button below the webview.
|
||||||
|
print("Device code finish URL detected!")
|
||||||
|
finishProcess(url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue