API 1.1 Always throws error

Solved!
Posted in General by Ajin Sat Jan 28 2017 20:10:39 GMT+0000 (UTC)·9·Viewed 2,727 times

I tried API 1.1 Tried to replicate the same code generated with API Key and Token, The response is always { "message": "Invalid Auth Token.", "success": false }
Ajin
Jan 28, 2017

URL used is production url

Ajin
Jan 28, 2017

Even the python wrapper throws the same

from instamojo_wrapper import Instamojo
api = Instamojo(api_key='', auth_token='')
response = api.payment_request_create(
... amount='3499',
... purpose='FIFA 16',
... send_email=True,
... email="foo@example.com",
... redirect_url="http://www.example.com/handle_redirect.py"
... )

response
{u'message': u'Invalid Auth Token.', u'success': False}

Instamojo
Jan 29, 2017

Please crosscheck the API key and Auth Token being passed.

Ajin
Jan 29, 2017

I am using the exact API Key and Auth Token generated in doc example page. Copy pasted the same code.

Ajin
Jan 29, 2017

import requests

headers = { "X-Api-Key": "", "X-Auth-Token": ""}
payload = {
... 'purpose': 'FIFA 16',
... 'amount': '2500',
... 'buyer_name': 'John Doe',
... 'email': 'foo@example.com',
... 'phone': '9999999999',
... 'redirect_url': 'http://www.example.com/redirect/',
... 'send_email': 'True',
... 'send_sms': 'True',
... 'webhook': 'http://www.example.com/webhook/',
... 'allow_repeated_payments': 'False',
... }
response = requests.post("https://www.instamojo.com/api/1.1/payment-requests/", data=payload, headers=headers)

print response.text
{
"success": false,
"message": "Invalid Auth Token."
}

>

Ajin
Jan 29, 2017

It is fixed. I was using the API and auth token generated in doc page. That was not the correct one. Solved when I used the api creds available at https://www.instamojo.com/integrations

Ajin
Jan 29, 2017

The API creds created along with the docs is causing confusion. either you remove it or put the correct api key and token with the code generated from docs

Instamojo
Feb 2, 2017

Docs page are public docs, we don't have any login there(at least not related to anyone's Instamojo account) and hence it is not possible to put someone's credentials there. Docs usually contain dummy data.


Instamojo marked this as solved
Ajin
Feb 2, 2017

Well I agree, but this page is causing confusion: https://www.instamojo.com/developers/

It says: We've generated the keys for you and included them in the examples.
And then there is the link to https://docs.instamojo.com/docs/

This will confuse people.

Markdown is allowed