API 1.1 Always throws error

Posted in General by Ajin Sat Jan 28 2017 20:10:39 GMT+0000 (Coordinated Universal Time)·9·Viewed 5,906 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 }
Jan 28, 2017

URL used is production url

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="[email protected]",
... redirect_url="http://www.example.com/handle_redirect.py"
... )

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

Jan 29, 2017

Please crosscheck the API key and Auth Token being passed.

Jan 29, 2017

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

Jan 29, 2017

import requests

headers = { "X-Api-Key": "", "X-Auth-Token": ""}
payload = {
... 'purpose': 'FIFA 16',
... 'amount': '2500',
... 'buyer_name': 'John Doe',
... 'email': '[email protected]',
... '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."


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

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

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.

marked this as solved
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