Question

I am trying to get the Balanced API Rent My Bikes Rails app up and running (https://github.com/balanced/rentmybikes-rails). In following the configuration tutorial on the site, I've been able to do everything (I think). However, when I try to rent a bike, or create a new listing, I receive the following error:

Balanced::Unauthorized(401)::Unauthorized:: GET https://api.balancedpayments.com/v1/merchants: authentication-required: Not permitted to perform index on merchants. Your request id is OHMa6172a32b14a11e395f3026ba7c1aba6. 

.env file, filled with test key and test market URI from the balancedpayments.com:

BALANCED_SECRET='ak-test-1dRppft8xoOg2GZ7FT2yFjWWMCUNFCXYI'
BALANCED_MARKETPLACE_URI='/v1/marketplaces/TEST-MP1vtjZnkpRR6DmfeAvyRwm3' 
BALANCED_CSRF='54cb4ff6c29811e2b033026ba7cd33d0'

I've also tried the full URI for the test marketplace, restarting the webBrick server afterward:

BALANCED_MARKETPLACE_URI='https://dashboard.balancedpayments.com/#/marketplaces/TEST-MP1Bb6nnn1xWxAYk05VwDzia/activity/transactions'

As well as test marketplaces that seem to work in the BalancedPayment documentation, including:

BALANCED_MARKETPLACE_URI='https://api.balancedpayments.com/marketplaces/TEST-MP1U7M592WT19sxxYwz98hLW'

Console shows:

16:35:49.796 POST http://localhost:3000/listings [HTTP/1.1 500 Internal Server Error 819ms]

Feeling a bit over my head, and Balanced's documentation isn't spelled out for Rails. Any ideas?

Was it helpful?

Solution

The 401 unauthorized leads me to believe that your .env file is not being loaded. If you want to use a .env file, you need to use the dotenv gem or run the application with Foreman.

/v1/marketplaces/TEST-MP1vtjZnkpRR6DmfeAvyRwm3 is your marketplace URI. https://dashboard.balancedpayments.com/#/marketplaces/TEST-MP1Bb6nnn1xWxAYk05VwDzia is for viewing your marketplace Dashboard, which is not the same thing.

In case the values you mentioned for BALANCED_SECRET and BALANCED_CSRF are real, even though they are for a test environment, I recommend you change them immediately.

If you need any additional help, feel free to drop by #balanced on Freenode IRC for direct assistance from Balanced developers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top