Btcpayserver refuses to work with a new token
See original GitHub issueThe guys when I try to create an invoice, I constantly have a 401 error, although I do everything according to the instructions:
info: BTCPayServer.Security.BitpayAuthentication+BitpayAuthHandler: Bitpay.Auth was not authenticated. Failure message: Invalid credentials
info: BTCPayServer.Security.BitpayAuthentication+BitpayAuthHandler: AuthenticationScheme: Bitpay.Auth was challenged.
perform the following steps:
- create a private key
- I get clientId using it (that is, I get SIN)
- I create a new token in the admin panel btcpayserver-> stores-> Access token
- copying the pairing code and sending a request to /tokens, the request looks like this: body {pairingCode: ‘j6jfkaf’, id: ‘Tf3WxtCNvPR9ATBjc14Wrw6EBxBS5AWn8Li’}
- in response, I successfully receive the token
- then I create an invoice {price: 900, currency: ‘USD’, token: ‘****’}
- add X-Identity and X-Signature headers
{
'X-Identity': Buffer.from(this.keypar.getPublic().EncodeCompressed()).ToString('hex'),
'X-Signature': this.sign(url, this.keypar).toString ('hex')
}
where url is host + uri + payload, and payload is JSON request body
After that, I successfully create an invoice, everything works! But after all, the current token will become obsolete after some time, and I added functionality to update it for example after 10 hours.
I save the private key to a file:
fs.writeFile('./key', JSON.stringify(keys.priv), 'utf-8', (err) => {
if (err) console.log('err generateKeys:', err)
})
Then, when restarting the service, I load the private key:
const file = fs.readFileSync('./key', 'utf8')
this.keypar = ec.keyFromPrivate(Buffer.from(JSON.parse(file), 'hex'))
To get a new token, I send a request to / tokens with the following parameters
{
label: 'label', // obtained by pairing pair code
id: 'Tf3WxtCNvPR9ATBjc14Wrw6EBxBS5AWn8Li',
facade: 'merchant'
}
In response, I get a new token and using it I try to create an invoice, but I get the error 401 (
Guys, explain to me how to organize work with the API?
I want to know, after pairing paircode, I can use the received data to create a new token, right? but it does not work (
The source code for my implementation is here: https://github.com/hazratgs/btcpay-node/blob/master/payqr.js
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
Yes, thank
Btw, is it related to https://github.com/btcpayserver/btcpayserver/issues/563 ?