/v2/registration/aadhaar/generateOtp Unauthorized 401

curl --request POST
–url https://dev.abdm.gov.in/gateway/v0.5/sessions
–header ‘Content-Type: application/json’
–cookie TS011c04bd=01115a1c90b56da225b41ff64b79b47e7157e17197e92714a43d80c507a1d72aa6302945890bb2262e55fb7ea8da2eb844d8c87b62
–data ‘{
“clientId”: “SBX_XXXXXX1”,
“clientSecret”: “807a3bf7-XXXX-XXXXX-XXXXXXXXXXX4”
}’


curl --request POST
–url https://healthidsbx.abdm.gov.in/api/v2/registration/aadhaar/generateOtp
–header ‘Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJBbFJiNVdDbThUbTlFSl9JZk85ejA2ajlvQ3Y1MXBLS0ZrbkdiX1RCdkswIn0.eyJleHAiOjE2NDI2ODE1MzEsImlhdCI6MTY0MjY4MDkzMSwianRpIjoiOTcwYmI5OWItNWRkNi00M2Y1LTliYWYtYzdjZDUxMmUwZTUzIiwiaXNzIjoiaHR0cHM6Ly9kZXYubmRobS5nb3YuaW4vYXV0aC9yZWFsbXMvY2VudHJhbC1yZWdpc3RyeSIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiI2YWQ2YjQ4Ny1mZTc1LTRiN2EtYjk1NS0wMzQ4OGU4OTRjNTgiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJTQlhfMDAwNTQxIiwic2Vzc2lvbl9zdGF0ZSI6IjMzMzVlODNiLWQ5YzEtNDgzMy05NWFlLTA2YzllMTQ3ZDhmOSIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiaHR0cDovL2xvY2FsaG9zdDo5MDA3Il0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJvZmZsaW5lX2FjY2VzcyJdfSwicmVzb3VyY2VfYWNjZXNzIjp7IlNCWF8wMDA1NDEiOnsicm9sZXMiOlsidW1hX3Byb3RlY3Rpb24iXX0sImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoib3BlbmlkIGVtYWlsIHByb2ZpbGUiLCJjbGllbnRJZCI6IlNCWF8wMDA1NDEiLCJjbGllbnRIb3N0IjoiMTAuMjMzLjY4LjEzMCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoic2VydmljZS1hY2NvdW50LXNieF8wMDA1NDEiLCJjbGllbnRBZGRyZXNzIjoiMTAuMjMzLjY4LjEzMCJ9.Z_j2ldhlN30z_zZA5TRFqEFB4jA-Z2uNudOZ4b7avDfQL7_DBOh4zDiEBSTo5CCXN-oZ8KJgH8kNvgMB6NJagXID-N3r9KWLT0V_DcmxHYpwndmrhZFXr5IRJowDqI6YUGwuX0g1HASFU7Xkx-7u9H7tVsEsczd_3SiYBpea77sIjEXjlqCI1UGsAkRm2MtGVyCOOEWGpBWPoHD6IkSt0x7rNC_SeQMq70jvXSDvg1IC0iUQ-h8EGUBE0te372FOpGhNeS_-J_00KsRxWWr60xLUueQme83cfGkr_GTESbg9A7Ah9TSWR6l-ZNwy-rwV6cBpHlPQPgOaNheJjiDYDw’
–header ‘Content-Type: application/json’
–cookie TS01c078b5=01115a1c9099416141ae54ed1365121edf9f9d60f680d31426c689af51ed47a088f8463b5db1ff53c92b9ca80331f73804ff1ce8ba
–data ‘{
“aadhaar”: “Z2W++CafwsEIru/gfCgZ6LZfPe5U/wxjPCIzgG4cbjV3OZldqr4E4wVFfM+okWJbvA473IccGVucMLj4bK4so0oAdkO3soIn9+5qRfv34+GGBYw1OiKVRhMpOS/Rozsjg5bK37bK+3956kJtjgJLMQA9/4FTUb74kTQTiu5nTvwDUCyXM8Txwxqk+QQyp43Cv8x+d31Zv89jp+y72QSxyeqTYrchlTXDTxPsDKNfOsRVQi2qMYAJvPIFbAesy/wQLR054s9R/RTgiGTC7xMbCVbezo3AqD4bB7BTjKLwpNJCYzgNw3RtPg2C2paf6QaDYCa1WywC+dbDkjPuZhKFco3bxNQAEeGypbFf/FQ2RPg0n7SLFb3fmsAmQ2oSaCuh6IRfQ93C14oR4vP6FHBnmx7D5tROP8s/lG0/xPcCNr6FmF6jAfStPIh8TusMdyWFdc4MIdL57WnMzmoMhHFVFCp23j3YZ1aha/wHd3fIGFsF5lExxpwc4UFJYwisFoAcCwjS+ZJHTYgOhZO6CKYoPsUNTbfI4nLCcluLneHl8TidNHe6Jcnlqcrh7NRCjPSkijzebApiue4c+WGDMZYde1FUZSmvxLq2s464t3I5bxvn8cL59WTDOsmu6TfyPd17KLAdXHMLyX5oIu6Zx7IliHiSwA9wBGDE4BD4qokQGCU=”
}’

Response:

{
“timestamp”: “2022-01-20T12:16:44.547+0000”,
“status”: 401,
“error”: “Unauthorized”,
“message”: “Unauthorized”,
“path”: “/api/v2/registration/aadhaar/generateOtp”
}

Please Help

Hi @KrishnaDhanushInfoth,

THe token doesn’t have Health Id role i.e. you are getting this error

image

Thank you for fixing the issue . Now we are able to call the services. Getting TxnId generated.
https://healthidsbx.abdm.gov.in/api/v2/registration/aadhaar/generateOtp

Response:
{
“txnId”: “5c50ae41-2cb0-xxxxxxxxx0e2d9a73521e”,
“mobileNumber”: “*******xxx05”
}

Greetings, I am currently facing the same issue, kindly let me know how the problem was fixed, how do i get a token with health ID role as mentioned in your reply? any help would be appreciated.

Thanks.

Please fallow below link for solution.

Hey @RohanChristopher707,

let us know your client id

thanks

@Shubhanshu_Shukla as requested, below is the client ID

SBX_000173

Thanks.

Hey @RohanChristopher707,

please check now,

thanks

@Shubhanshu_Shukla the issue still persists, I still get the 401 unauthorised when i pass the access token to the endpoints.

“timestamp”: “2022-01-25T13:06:21.836+0000”,
“status”: 401,
“error”: “Unauthorized”,
“message”: “Unauthorized”,
“path”: “/api/v1/search/searchByMobile”

@depakpant,

Can you please take this up?

Hi @RohanChristopher707,

Please check the role provide in your token because these APIs are working absolutely fine.

Thanks
Deepak

@Shubhanshu_Shukla I am facing the same issue my client ID is SBX_002827