bitpay / node-bitpay-client

A Node.js module and command line client for interacting with BitPay's Cryptographically Secure API
102 stars 95 forks source link

Can't log in correctly to access non-public methods #30

Closed imrehg closed 9 years ago

imrehg commented 10 years ago

When I use the default bitpay login -e <myemail> method, I get this message during the authorization:

No private key specified. Only public methods allowed.

Afterwards, if I for example want to create bills, naturally I get this error message:

{ error: 'You do not have access to this resource. (user)' }

On the other hand, I can't seem to find an example for logging in to access the merchant functions. If I modify the login action similarly as e.g. I see in the examples/create-bill.js, along the lines of

var encPrivkey = fs.readFileSync(HOME + '/.bitpay/api.key').toString(); var config = require('../config'); var privkey = bitauth.decrypt(config.keyPassword, encPrivkey); var client = new BitPay(privkey);

and use that client in the bitpay script's login action, the results is:

Error: { error: 'Unauthorized sin' }
Key associated! Check your email to approve access.

So either way, i can't seem to actually log in such a way that I could run e.g. the examples/create-bill.js example correctly... What am I missing?

tacticalchihuahua commented 10 years ago

Apologies. The examples are in a bit of a disarray as we are pretty rapidly iterating on our new API. In regard to this specific error:

{ error: 'You do not have access to this resource. (user)' }

This means that the client attempted to create a bill using the "user" facade - which is not authorized to do so. I'd check to make sure that you have a merchant token associated with your key.

If you pull the latest code (and we have made backwards incompatible changes), use the CLI tool to get your tokens:

$ bitpay request -T user -R tokens

If you are setup correctly, you should get back something like this:

[ { "merchant": "<% token_string %>" } ]

Let me know your results!

tacticalchihuahua commented 9 years ago

Closing, due to inactivity. Feel free to reopen if you are still having issues.