Closed ikarstein closed 1 month ago
Did you create a token via the cloud API? You cannot use username+password auth on the local endpoint, only on the cloud endpoint.
The token created on the cloud API can be used for local authentication, as described in the instructions in this repo.
Thank you @iMicknl !
Now I can login and get a JSESSIONID cookie.
I use this URL https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/login
Now I can register a token using https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/config/$pin/local/tokens/generate
where $pin
is the PIN of my TaHoma Switch box.
But when I try to "activate" the token using https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/config/$pin/local/tokens
(http methon POST
) I get: 400 Invalid Request. As request body I use this JSON string {"label":"mytoken", "token":"$token", "scope": "devmode"}
where $token
is replaced by the token that I got from /tokens/generate
.
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$pin = "0000-0000-0000" #real PIN replaced here...
$cloud = "ha101-1.overkiz.com"
Invoke-WebRequest "https://$cloud/enduser-mobile-web/enduserAPI/login" `
-Method post -ContentType "application/x-www-form-urlencoded" `
-Body 'userId=xxxxx@example.com&userPassword=************' -SessionVariable "sess"
$r = Invoke-RestMethod "https://$cloud/enduser-mobile-web/enduserAPI/config/$pin/local/tokens/generate" `
-Method Get -ContentType "application/json" `
-WebSession $sess
write-host "$($r.token)"
Invoke-WebRequest "https://$cloud/enduser-mobile-web/enduserAPI/config/$pin/local/tokens" `
-Method Post -ContentType "application/json" `
-WebSession $sess `
-Body "{""label"":""mytoken"", ""token"":""$($r.token)"", ""scope"":""devmode""}"
This is my Powershell script. Maybe some parts are also helpful to others :-)
Hi @ikarstein, Have you been able to solve the token's registration issue ?
@llavorel-somfy Not really. I could generate a token but I cannot activate it as mentioned in the documentation.
I have a valid JSESSIONID cookie and I see the token with line write-host "$($r.token)"
But the activation fails with result "400 Invalid Request", using the token and the session cookie.
@ikarstein are you sure your body is correct? I am not very familiar with Powershell, but why are you using double quotes?
-Body "{""label"":""mytoken"", ""token"":""$($r.token)"", ""scope"":""devmode""}"
$body = @{
"scope" = "devmode"
"label" ="myToken"
"token" = $r.token
}
Invoke-WebRequest "https://$cloud/enduser-mobile-web/enduserAPI/config/$pin/local/tokens" `
-Method Post
-ContentType "application/json" `
-WebSession $sess `
-Body ($body|ConvertTo-Json)
Have you tried something like this?
Double quotes inside a string is the escape sequence for a normal quote.
write-host "x""x"
writes to the console: x"x
Now I tried your suggestion anyways but get an error during "login" that worked last time...
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$pin = "0000-0000-0000" #real PIN replaced here...
$cloud = "ha101-1.overkiz.com"
Invoke-WebRequest "https://$cloud/enduser-mobile-web/enduserAPI/login" `
-Method post -ContentType "application/x-www-form-urlencoded" `
-Body 'userId=xxxxx@example.com&userPassword=************' -SessionVariable "sess"
... results in 401 Not authorized
Hi all!
How can I login to Tahoma Switch with enabled Developer Mode and App Credentials from https://developer.somfy.com/user/me/apps ?
My "Switch" is online. Developer Mode is enabled.
I try to login with userId and userPassword ("Login") and get this result:
{"error":"Missing authorization token.","errorCode":"RESOURCE_ACCESS_DENIED"}
Url used: "https://$hostname/enduser-mobile-web/enduserAPI/login" ... where $hostname is a variable for
<ip>:8443
.