pawamoy / aria2p

Command-line tool and library to interact with an aria2c daemon process with JSON-RPC.
https://pawamoy.github.io/aria2p
ISC License
479 stars 93 forks source link

aria2p.client.ClientException: Unauthorized #92

Closed billouetaudrey closed 3 years ago

billouetaudrey commented 3 years ago

Hi,

I try to launch aria2p but I have an error but I don't understand :'( Aria2c work fine ( webui )

Anyone can help me ?

Aria2p (0.10.4) ( Linux raspberrypi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l)

Thanks

root@raspberrypi:~# aria2p
Traceback (most recent call last):
  File "/usr/local/bin/aria2p", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/aria2p/cli.py", line 82, in main
    api.client.get_version()
  File "/usr/local/lib/python3.9/site-packages/aria2p/client.py", line 1496, in get_version
    return self.call(self.GET_VERSION)
  File "/usr/local/lib/python3.9/site-packages/aria2p/client.py", line 261, in call
    return self.res_or_raise(self.post(self.get_payload(method, params, msg_id=msg_id)))
  File "/usr/local/lib/python3.9/site-packages/aria2p/client.py", line 391, in res_or_raise
    raise Client.response_as_exception(response)
aria2p.client.ClientException: Unauthorized
jonnieey commented 3 years ago

According to Aria2c manual

RPC authorization secret token As of 1.18.4, in addition to HTTP basic authorization, aria2 provides RPC method-level authorization. In a future release, HTTP basic authorization will be removed and RPC method-level authorization will become mandatory. To use RPC method-level authorization, the user has to specify an RPC secret authorization token using the --rpc-secret option. For each RPC method call, the caller has to include the token prefixed with token:. Even when the --rpc-secret option is not used, if the first parameter in the RPC method is a string and starts with token:, it will removed from the parameter list before the request is being processed.

Therefore you need to set secret token in your aria2 configuration file. example

enable-rpc=true rpc-listen-all=true rpc-secret=secret

Then use aria2p as : aria2p -s secret

billouetaudrey commented 3 years ago

Hey, thanks for your help, not working :(

My .aria2/aria2.conf :

# For full reference:
# https://aria2.github.io/manual/en/html/aria2c.html
##
dir=/home/dietpi/MiniDLNA
file-allocation=trunc
continue=true
# daemon=true
##
log=/home/dietpi/.aria2/aria2.log
console-log-level=warn
log-level=notice
##
max-concurrent-downloads=5
max-connection-per-server=10
min-split-size=5M
split=10
disable-ipv6=true
##
input-file=/home/dietpi/.aria2/aria2.session
save-session=/home/dietpi/.aria2/aria2.session
save-session-interval=30
##
enable-rpc=true
rpc-allow-origin-all=true
rpc-listen-all=true
rpc-listen-port=6800
rpc-secret=***
##
follow-torrent=mem
follow-metalink=mem
enable-dht6=false
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
seed-time=0
#seed-ratio=1.0
bt-seed-unverified=true
bt-save-metadata=true

When do aria2p -s ***

dietpi@raspberrypi:~$ aria2p -s ***
Traceback (most recent call last):
  File "/usr/local/bin/aria2p", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/aria2p/cli.py", line 82, in main
    api.client.get_version()
  File "/usr/local/lib/python3.9/site-packages/aria2p/client.py", line 1496, in get_version
    return self.call(self.GET_VERSION)
  File "/usr/local/lib/python3.9/site-packages/aria2p/client.py", line 261, in call
    return self.res_or_raise(self.post(self.get_payload(method, params, msg_id=msg_id)))
  File "/usr/local/lib/python3.9/site-packages/aria2p/client.py", line 391, in res_or_raise
    raise Client.response_as_exception(response)
aria2p.client.ClientException: Unauthorized
billouetaudrey commented 3 years ago

this work for me aria2p -H http://127.0.0.1 -s secret

Is it possible to set default host for don't need to use -H ?

pawamoy commented 3 years ago

Hello! The default host is already http://localhost. If it doesn't work for you, it's probably an issue on your system!

billouetaudrey commented 3 years ago

Hi ;)

Localhost not working too, only local ip and local hostname work :'(

pawamoy commented 3 years ago

You could try one of the solutions listed here: http://stackoverflow.com/questions/12491750/ddg#39757106

pawamoy commented 3 years ago

I'll close this as I don't think there's anything we can do on aria2p's side, but feel free to reopen if you can prove otherwise :slightly_smiling_face:

billouetaudrey commented 3 years ago

Finally fixed :) Dunno how because I do lot of fixed.

I think I know why bug :)

Thanks you for ur help :D