cowinapi / developer.cowin

This group is created to facilitate technical and integration discussions related to cowin platform. API related contents can be obtained at API setu portal https://apisetu.gov.in/public/marketplace/api/cowin
115 stars 30 forks source link

API Key Not Working #465

Open sharanplan8 opened 3 years ago

sharanplan8 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

Thanks for update, after convert OPT into sha256 its works in postman. Now I am consuming APIS in Microsoft Power Automate with "/generateOTP" endpoint, still getting 403 error. Please see the screenshot below:

image


From: Bhagwan Sahane @.> Sent: Monday, June 28, 2021 7:10 PM To: cowinapi/developer.cowin @.> Cc: Chetan Harish Khanapure @.>; Mention @.> Subject: Re: [cowinapi/developer.cowin] API Key Not Working (#465)

@ChetanKhanapurehttps://github.com/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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/cowinapi/developer.cowin/issues/465#issuecomment-869694444, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APG3UIVQFLBWTF6ODHX23T3TVB3TTANCNFSM47JNWZVA.

big89 commented 3 years ago

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