question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BitPay Node.JS Client error interacting with BTCPayServer "no-bitid"

See original GitHub issue

I’ve successfully paired the Bitpay Node.JS client with my local instance of BTCPayServer, but when i try to invoke the api i’m getting this weird “no-bitid” error.

root@ubuntu:/home/ubuntu/node_modules/bitpay/lib# bitpay pair
Do you have a pairing code?
no

Okay, we can get a pairing code, please choose a facade:
  1) Point of Sale
  2) Merchant
  : 1

 Your token information:

 Client ID:     Tf71..................................ZYR3
 Pairing Code:  zEXgMr5
 Label:         node-bitpay-client-ubuntu
 Facade:        pos


 Your pairing code will be available until: Wed Apr 11 2018 20:17:57 GMT-0300 (-03)


 Pair this client with another organization by giving an administrator this pairing code:
 zEXgMr5

 Pair this client with your organization:
 https://0.0.0.0:23000/api-access-request?pairingCode=zEXgMr5

Then i access the link on the browser and get the message “Pairing is successful”, the token is now activated.

But when i try to invoke any methods i only get errors

root@ubuntu:/home/ubuntu/node_modules/bitpay/lib# bitpay whoami
Enter Key Password:
Error: { error: 'no-bitid' }
root@ubuntu:/home/ubuntu/node_modules/bitpay/lib# bitpay request -T pos -R invoices
Enter Key Password:
Error: { error: 'no-bitid' }
root@ubuntu:/home/ubuntu/node_modules/bitpay/lib# bitpay request -T pos -X post -R invoices -P '{"price": 15, "currency": "USD"}'
Enter Key Password:
Error: { error: 'no-bitid' }

I’ve commented the lines that check the type of the model of “controller.User.Identity” on “Extensions.cs” (just to help debugging)

public static BitIdentity GetBitIdentity(this Controller controller, bool throws = true) {
//    if (!(controller.User.Identity is BitIdentity))
//        return throws ? throw new UnauthorizedAccessException("no-bitid") : (BitIdentity)null;
    return (BitIdentity)controller.User.Identity;
}

Now this error is thrown at server console

crit: PayServer:      Unhandled exception in BTCPayMiddleware
System.InvalidCastException: Unable to cast object of type 'System.Security.Claims.ClaimsIdentity' to type 'BTCPayServer.Authentication.BitIdentity'.
   at BTCPayServer.Extensions.GetBitIdentity(Controller controller, Boolean throws) in /home/ubuntu/btcpay/btcpayserver/BTCPayServer/Extensions.cs:line 117

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
NicolasDoriercommented, Apr 13, 2018

No I can’t fix this easily actually. Well anyway it works good! 😃

1reaction
NicolasDoriercommented, Apr 13, 2018

w00t… anyway it is a btcpay bug you had the 80 in the url… will check if I can solve this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node Full SDK
BitPay NodeJS client. This SDK provides a convenient abstraction of BitPay's cryptographically-secure API and allows payment gateway developers to focus on ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found