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() {
|
||||||
|
|
@ -126,7 +126,7 @@ Page {
|
||||||
print("New thing setup")
|
print("New thing setup")
|
||||||
internalPageStack.push(paramsPage)
|
internalPageStack.push(paramsPage)
|
||||||
|
|
||||||
// Reconfigure
|
// Reconfigure
|
||||||
} else if (root.thing) {
|
} else if (root.thing) {
|
||||||
print("Existing thing")
|
print("Existing thing")
|
||||||
// There are params. Open params page in any case
|
// There are params. Open params page in any case
|
||||||
|
|
@ -134,7 +134,7 @@ Page {
|
||||||
print("Params:", root.thingClass.paramTypes.count)
|
print("Params:", root.thingClass.paramTypes.count)
|
||||||
internalPageStack.push(paramsPage)
|
internalPageStack.push(paramsPage)
|
||||||
|
|
||||||
// No params... go straight to reconfigure/repair
|
// No params... go straight to reconfigure/repair
|
||||||
} else {
|
} else {
|
||||||
print("no params")
|
print("no params")
|
||||||
switch (root.thingClass.setupMethod) {
|
switch (root.thingClass.setupMethod) {
|
||||||
|
|
@ -389,7 +389,7 @@ Page {
|
||||||
id: paramRepeater
|
id: paramRepeater
|
||||||
model: engine.jsonRpcClient.ensureServerVersion("1.12") || d.thingDescriptor == null ? root.thingClass.paramTypes : null
|
model: engine.jsonRpcClient.ensureServerVersion("1.12") || d.thingDescriptor == null ? root.thingClass.paramTypes : null
|
||||||
delegate: ParamDelegate {
|
delegate: ParamDelegate {
|
||||||
// Layout.preferredHeight: 60
|
// Layout.preferredHeight: 60
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
enabled: !model.readOnly
|
enabled: !model.readOnly
|
||||||
paramType: root.thingClass.paramTypes.get(index)
|
paramType: root.thingClass.paramTypes.get(index)
|
||||||
|
|
@ -558,13 +558,24 @@ Page {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
url: oAuthPage.oAuthUrl
|
url: oAuthPage.oAuthUrl
|
||||||
|
|
||||||
|
function finishProcess(url) {
|
||||||
|
print("Confirm pairing")
|
||||||
|
engine.thingManager.confirmPairing(d.pairingTransactionId, url)
|
||||||
|
busyIndicator.running = true
|
||||||
|
oAuthWebView.visible = false
|
||||||
|
}
|
||||||
|
|
||||||
onUrlChanged: {
|
onUrlChanged: {
|
||||||
print("OAUTH URL changed", url)
|
print("OAUTH URL changed", url)
|
||||||
if (url.toString().indexOf("https://127.0.0.1") == 0) {
|
if (url.toString().indexOf("https://127.0.0.1") == 0) {
|
||||||
print("Redirect URL detected!");
|
print("Redirect URL detected!")
|
||||||
engine.thingManager.confirmPairing(d.pairingTransactionId, url)
|
finishProcess(url)
|
||||||
busyIndicator.running = true
|
} else if (url.toString().indexOf("device-complete") >= 0) {
|
||||||
oAuthWebView.visible = false
|
// 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