What's new

wget with authorization?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Bamsefar

Senior Member
So I have a need to send http request like:
Code:
wget http://192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3

However that will result in:
wget: server returned error: HTTP/1.1 401 Unauthorized

So I need to add user/passwd, and tried things like:
Code:
wget http://admin:xxx@192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3

But this also fails with a <HTTP/1.1 400> error.

Any ideas how to get this working?
 
Hi,

try :

Code:
wget --http-user=admin --http-password=xxxx http://192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3

Hint ;-)
Code:
wget --help
 
Last edited:
Well, this is Busybox, so your hint ;-) is incorrect:

admin@RT-AC87U-72B0:/tmp/home/root# wget: unrecognized option `--http-user=admin '
BusyBox v1.20.2 (2014-09-20 14:51:14 EDT) multi-call binary.

Usage: wget [-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FIL E]
[--header 'header: value'] [-Y|--proxy on/off] [-P DIR]
[--no-check-certificate] [-U|--user-agent AGENT] [-T SEC] URL...

Retrieve files via HTTP or FTP

-s Spider mode - only check file existence
-c Continue retrieval of aborted transfer
-q Quiet
-P DIR Save to DIR (default .)
-T SEC Network read timeout is SEC seconds
-O FILE Save to FILE ('-' for stdout)
-U STR Use STR for User-Agent header
-Y Use proxy ('on' or 'off')
 
I think you have the answer there....busybox wget doesn't support authentication for the transfer.

You will need to install either Optware or Entware (depending on your router) to get a full version of wget.

I did a quick search for you if there were any pre-compiled binaries for the ARM routers of either wget or curl that you could use, but didn't come up with anything. If someone already installed Optware/Entware, they may be able to copy the binaries and libraries off for you to use (the binaries are compiled with SSL support so you would also need the SSL libs).
 
I think you have the answer there....busybox wget doesn't support authentication for the transfer.

You will need to install either Optware or Entware (depending on your router) to get a full version of wget.

I did a quick search for you if there were any pre-compiled binaries for the ARM routers of either wget or curl that you could use, but didn't come up with anything. If someone already installed Optware/Entware, they may be able to copy the binaries and libraries off for you to use (the binaries are compiled with SSL support so you would also need the SSL libs).

Authentication is enabled, but not sure why it wouldn't work:

Code:
merlin@mint-dev ~/asuswrt.ac87/release/src/router/busybox $ cat config_current | grep WGET
CONFIG_WGET=y
CONFIG_FEATURE_WGET_AUTHENTICATION=y
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
CONFIG_FEATURE_WGET_TIMEOUT=y
CONFIG_FEATURE_WGET_STATUSBAR=y
merlin@mint-dev ~/asuswrt.ac87/release/src/router/busybox $
 
I have, thanks to google, installed OptWare (thanks to RMerlin!) and then did a few commands:

Code:
ipkg update
ipkg upgrade
ipkg install wget-ssl

Now I can use --user and --password. But now I have another error...
 
This one is odd, it's like it cuts out something:
Code:
admin@RT-AC87U-72B0:/tmp/home/root# /opt/bin/wget --http-user=admin --http-password=xxx http://192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3
admin@RT-AC87U-72B0:/tmp/home/root# --2014-10-21 18:40:44--  http://192.168.1.131/api/callAction?deviceID=14
Connecting to 192.168.1.131:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to 192.168.1.131:80.
HTTP request sent, awaiting response... 400 Bad Request
2014-10-21 18:40:44 ERROR 400: Bad Request.

Sending:
Code:
/opt/bin/wget http://admin:xxx@192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3
Gives the same error.

Now removing userid/password generates:
Code:
admin@RT-AC87U-72B0:/tmp/home/root# /opt/bin/wget http://192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3
admin@RT-AC87U-72B0:/tmp/home/root# --2014-10-21 18:39:50--  http://192.168.1.131/api/callAction?deviceID=14
Connecting to 192.168.1.131:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authorization failed.
 
Just for clarity: The http string is 100% correct - it always works in Chrome/Firefox and iRule. Something is odd here...
 
Authentication is enabled, but not sure why it wouldn't work:

Code:
merlin@mint-dev ~/asuswrt.ac87/release/src/router/busybox $ cat config_current | grep WGET
CONFIG_WGET=y
CONFIG_FEATURE_WGET_AUTHENTICATION=y
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
CONFIG_FEATURE_WGET_TIMEOUT=y
CONFIG_FEATURE_WGET_STATUSBAR=y
merlin@mint-dev ~/asuswrt.ac87/release/src/router/busybox $

I stand corrected....thanks.

I just tried it using the format in your first post

Code:
[url]http://user:passwd@address[/url]
and it did work fine for me.

Just a thought....do you have any special characters in your password that might need to be escaped?
 
Password is just 9 letters and 3 digits. No fancy at all...

I wonder if there is something in my http string that fails. I do have a & in there for extra parameters.

I have tried cURL also, and with:

Code:
admin@RT-AC87U-72B0:/tmp/home/root# /opt/bin/curl -v -u=admin:xxx http://192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=4
admin@RT-AC87U-72B0:/tmp/home/root# > GET /api/callAction?deviceID=14 HTTP/1.1
> Authorization: Basic <xxx removed>
> User-Agent: curl/7.24.0 (arm-unknown-linux-gnu) libcurl/7.24.0 OpenSSL/0.9.8v zlib/1.2.5
> Host: 192.168.1.131
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Date: Tue, 21 Oct 2014 16:55:45 GMT
< Server: 0.9
< Content-Length: 0
< WWW-Authenticate: Basic realm="fibaro"
< Content-Type: text/plain
<
This seems to work, however nothing happens in my Fibaro HC2 box (it should turn off all lights - and it is dark here in Sweden ;-) however nothing happens, works in Chrome/Firefox...).
 
Oh now I am angry!!!!!!! <---- On my self for missing something this obvious...

I only had to put the http string inside " ":

Code:
/opt/bin/wget --http-user=admin --http-password=xxx "http://192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3"

This also works by the way:
Code:
wget "http://admin:xxx@192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3"
 
Last edited:
Oh now I am angry!!!!!!! <---- On my self for missing something this obvious...

I only had to put the http string inside " ":

Congrats! Don't feel bad....a bunch of us missed it. But isn't it nice when the lightbulb finally lights.:D
 
Well, this is Busybox, so your hint ;-) is incorrect:

Oops sorry, I didn't even know that wget is included in busybox.

I have already installed entware in the very first time i get the router with "normal" wget

and, if I can ask , why optware, not entware ? I was thinking that entware is the successor of optware ?
 
and, if I can ask , why optware, not entware ? I was thinking that entware is the successor of optware ?

There are differences on the hardware platform:

AC56 / AC68 / AC87 are all using ARM based CPUs

The reste are using MIPS based CPUs, and MIPS based are the only one supported by EntWare.

ARM based can only use OptWare.

So it come's down to hardware design I'm afraid. :D
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top