Unable to authenticate. TypeError: token.finally is not a function
After running the commands,
IDP=https://drive.verborgh.org
USERNAME=ruben
PASSWORD=ruben
URL=https://drive.verborgh.org/inbox/
curl "$URL" -H 'Authorization: Bearer '`solid-bearer-token "$IDP" "$USERNAME" "$PASSWORD" "$URL"`
I get the error,
token.finally(() => saveIdentityManager(identityManager, settingsFile));
^
TypeError: token.finally is not a function
at Object.<anonymous> (/opt/conda/lib/node_modules/@solid/cli/bin/solid-bearer-token:24:14)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
Access to https://drive.verborgh.org/inbox/ requires authorization
Any suggestion about what the issue might be?
Thank you!
What's your Node version? You'll need 8 or up.
Also you'll need your own host and password 😉
Thank you. Updating it to node 8 solved the issue. However, I get a different issue.
root@0c81d86e0603:/home/solid-cli# solid-bearer-token "$IDP" "$USERNAME" "$PASSWORD" "$URL"
{ FetchError: request to https://solid:8443/.well-known/openid-configuration failed, reason: self signed certificate
at ClientRequest.<anonymous> (/usr/local/lib/node_modules/@solid/cli/node_modules/node-fetch/index.js:133:11)
at ClientRequest.emit (events.js:182:13)
at TLSSocket.socketErrorListener (_http_client.js:399:9)
at TLSSocket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process.internalTickCallback (internal/process/next_tick.js:72:19)
name: 'FetchError',
message:
'request to https://solid:8443/.well-known/openid-configuration failed, reason: self signed certificate',
type: 'system',
errno: 'DEPTH_ZERO_SELF_SIGNED_CERT',
code: 'DEPTH_ZERO_SELF_SIGNED_CERT' }
Do you have a suggestion on how to resolve it?
EDIT:
I added the line below to the bin/solid-bearer-token file which resolved the issue.
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
However I run into yet another issue.
root@0c81d86e0603:/home/solid-cli/bin# solid-bearer-token "$IDP" "$USERNAME" "$PASSWORD" "$URL"
(node:1312) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
{ FetchError: request to https://localhost:8443/jwks failed, reason: connect ECONNREFUSED 127.0.0.1:8443
at ClientRequest.<anonymous> (/home/solid-cli/node_modules/node-fetch/index.js:133:11)
at ClientRequest.emit (events.js:182:13)
at TLSSocket.socketErrorListener (_http_client.js:399:9)
at TLSSocket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process.internalTickCallback (internal/process/next_tick.js:72:19)
name: 'FetchError',
message:
'request to https://localhost:8443/jwks failed, reason: connect ECONNREFUSED 127.0.0.1:8443',
type: 'system',
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED' }
Import to note I am running my own solid server, inside a docker machine, and also a client, in another docker machine. I think its giving the localhost response but of course that is not the localhost in the client.
I appreciate any help!
Yes, Node is right to give that warning.
Not entirely sure why it is refused, is the server still running? Can you request that file from within a browser?
Actually, given you have a self-signed cert, you also want to run the server with bin/solid-test rather than bin/solid.
I get a similar error
/usr/local/lib/node_modules/@solid/cli/bin/solid-bearer-token:24
token.finally(() => saveIdentityManager(identityManager, settingsFile));
^
TypeError: token.finally is not a function
at Object.<anonymous> (/usr/local/lib/node_modules/@solid/cli/bin/solid-bearer-token:24:14)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
node -v v8.10.0
PS running against solid.community
@solid-pay Are you sure the Node version that is running the script is the same as the node version you get when doing node. (I have seen systems where that is not the case, that would be one possible explanation)
@RubenVerborgh thanks for the quick reply ( solidpay == melvin :) )
I believe im using node 8, I tried from master :
node -v
v8.10.0
node bin/solid-bearer-token https://melvin.solid.community secret secret https://melvin.solid.community/inbox
/home/melvin/mel/solid-cli/bin/solid-bearer-token:24
token.finally(() => saveIdentityManager(identityManager, settingsFile));
^
TypeError: token.finally is not a function
at Object.<anonymous> (/home/melvin/mel/solid-cli/bin/solid-bearer-token:24:14)
Very weird, what does a console.log of token give?