401 Unauthorized

  • Hi,

    I'm trying to swith a relay. Works perfectly when theres no authorization is set on the device. As soon it's enabled error 401 appears. What am I overlooking? Shelly Pro1 | Id: 30C6F78B647C | Firmware: 0.14.1 | Web: 767992a8

    Authorization header:

    DefaultRequestHeaders{Authorization: Digest username="admin", realm="30C6F78B647C", nonce="de589c4080ba4bff9125ffbc14047020", uri="http://10.1.100.245:80/relay/0?turn=off&timer=4", cnonce="8ae56f4f6aac49ea8f55da2c518c4da2", response="835867304fdca816c1d2515e074dbdf14680e86f9332eed29b63e2391d2ad38f", algorithm=SHA-256 }System.Net.Http.Headers.HttpRequestHeaders

    The response I get:

    response{StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers: { WWW-Authenticate: Digest qop="auth", realm="shellypro1-30c6f78b647c", nonce="64789f14", algorithm=SHA-256 Content-Length: 0 }}System.Net.Http.HttpResponseMessage
    Headers{WWW-Authenticate: Digest qop="auth", realm="shellypro1-30c6f78b647c", nonce="64789f14", algorithm=SHA-256 }System.Net.Http.Headers.HttpResponseHeaders
  • Hi,

    I know this is an old thread, but it's the same error for me.

    Quick background, I have a Shelly Button 1 (for simplicity) activating a Central Heating Relay (mini Gen3), switching it on or off.

    The relay is ALSO on a schedule, so I wanted to write a simple URL sent from the Shelly Button that if I select OFF, it disables the Input, which I understand essentially "deactivates" the Switch and thus any scheduled "On" calls.

    Switching the Shelly Button 1 back "On" should reactivate the Relay, setting it to "On" by setting the Toggle (in_mode: follow) and "initial_state":"match_input"}. I assume the schedule just continues from there. Small disclaimer, I am also investigating just disabling the schedules, but it's coming along as a lot more complicated, with scripts.

    The OFF URL called from Shelly Button 1 to the CH Relay is:

    Code
    http://admin:password@192.168.47.127/rpc/Switch.SetConfig?id=0&config={"in_mode":"detached","initial_state":"off"}

    The ON URL called from Shelly Button 1 to the CH Relay is:

    Code
    http://admin:password@192.168.47.127/rpc/Switch.SetConfig?id=0&config={"in_mode":"follow","initial_state":"match_input"}

    If I leave OUT the Authentication (i.eadmin:password@), it works fine, testing OFF and ON as follows:

    Code
    http://192.168.47.127/rpc/Switch.SetConfig?id=0&config={"in_mode":"detached","initial_state":"off"}
    http://192.168.47.127/rpc/Switch.SetConfig?id=0&config={"in_mode":"follow","initial_state":"match_input"}

    But when Authentication is added back in, (also using a Chrome Browser), the "sign in" text box in Chrome keeps prompting for the username and password. It doesn't take the password.

    If I click cancel (the Chrome Authorization dialogue), I see:

    Code
    {
      "restart_required": false
    }

    The odd thing is if I just issue a simple GetConfig (as below, I can type in the admin:password in the dialogue box and it gets the result of GetConfig just fine (EDIT: I understand this is one of very few exceptions).

    Code
    http://192.168.47.127/rpc/Switch.GetConfig?id=0

    Does anyone know why does it not "take" the passwordand how to get around this please?

    Thx!

    NOTE1: The Chrome Browser console responds with

    Code
    Failed to load resource: the server responded with a status of 401 ()

    NOTE2: I used HttpToolkit and got this output, if it helps? See METHOD GET.txt file attached.

    METHOD GET.txt1.14 kB · 0 downloads