In addition to above correct answer if you use the username and password generated by the monero-wallet-rpc
make sure to copy it correctly!
Example:
Starting monero-wallet-rpc
with:
./monero-wallet-rpc --rpc-bind-port 18083 --wallet-file "/path/to/your/walletfile" --prompt-for-password
generates a new monero-wallet-rpc.18083.login
login-credential file.
When printing the username:password
combination from monero-wallet-rpc.18083.login
with
cat monero-wallet-rpc.18083.login
it printed something like this for me:
monero:uAD5d089I7VEm9sJTN9epA==%
The last character %
is an escape character. The password is: uAD5d089I7VEm9sJTN9epA==
This curl succeeded:
curl --digest -u monero:uAD5d089I7VEm9sJTN9epA== -X post -d '{"jsonrpc":"2.0","id":"0","method":"get_balance"}' -H 'Content-Type: application/json' http://127.0.0.1:18083/json_rpc
Note: tested on Mac with Monero 'Oxygen Orion' (v0.17.1.1-release)