Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Key Not Working #465

Open
sharanplan8 opened this issue Jun 25, 2021 · 7 comments
Open

API Key Not Working #465

sharanplan8 opened this issue Jun 25, 2021 · 7 comments

Comments

@sharanplan8
Copy link

We have tried the demo Cowin API on the website but encountered the following error:

'Failed to Fetch'

Co-win

Steps to recreate:

  1. Open the Cowin API website - API Setu
  2. In the Authentication APIs select generateOTP
  3. Authenticate with the API key provided on their website
  4. Click “Try it out”
@big89
Copy link

big89 commented Jun 25, 2021

Try same with any REST API client like Postman OR in any programming language like PHP.

Also, this APIs are only accessible from Indian IPs.

Thanks,
Logicmaker

@rupesh-jaiswal
Copy link

for trying with postman or from programming language
how I can I use the protected access key
please let us know if there is documentation on how to consume the api from postman or programming language

@big89
Copy link

big89 commented Jun 27, 2021

@rupesh-jaiswal Co-Win API portal already given Swagger documentation which can generate cURL request for each API.

For refrence you can check below PHP script for Generate OTP Protected API with given Sandbox API Key -

`<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://cdndemo-api.co-vin.in/api/v2/auth/generateOTP');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"mobile":"9876543210"}');

$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'X-Api-Key: 3sjOr2rmM52GzhpMHjDEE1kpQeRxwFDr4YcBEimi';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);

echo $result;
?>`

Similarly check for other APIs on API portal as no any other reference provided except that.

Thanks,
Logicmaker

@ChetanKhanapure
Copy link

ChetanKhanapure commented Jun 28, 2021

Here the txnId generating in postman & OTP is getting on my mobile

image

But when I tried to consume txnid & OTP in the "/confirmOTP" endpoint then show invalid OTP

image

@big89
Copy link

big89 commented Jun 28, 2021

@ChetanKhanapure Password mush be SHA256 hashed in Confirm OTP API call.

Refer below link for reference -
https://emn178.github.io/online-tools/sha256.html

Thanks,
Logicmaker

@ChetanKhanapure
Copy link

ChetanKhanapure commented Jun 28, 2021 via email

@big89
Copy link

big89 commented Jun 28, 2021

Make sure that you are calling this APIs from Indian IPs only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants