# Swagger request getting 401 response after registration

**URL:** <https://community.open-emr.org/t/swagger-request-getting-401-response-after-registration/24269>\
**Category:** OpenEMR Development\
**Tags:** standard\_api\
**Created:** [January 11, 2025, 11:14pm UTC](https://community.open-emr.org/t/swagger-request-getting-401-response-after-registration/24269 "2025-01-11T23:14:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![saeed](https://community.open-emr.org/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@saeed](https://community.open-emr.org/u/saeed)\
**Post date:** [January 11, 2025, 11:14pm UTC](https://community.open-emr.org/t/swagger-request-getting-401-response-after-registration/24269/1 "2025-01-11T23:14:09Z")

</div>

I have the same issue.

registration is done via postman as in the picture.  
authentication is done via swagger as seen in the screenshot.  
Get api/patient did not work as seen in the screenshot because the server denied! But the authentication step worked just fine!

 ![101](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/d/f/df0b7b27a847dfd15b49c5f21b693d3086e40520.png)

---

<div class="post-metadata">

**Author:** ![saeed](https://community.open-emr.org/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@saeed](https://community.open-emr.org/u/saeed)\
**Post date:** [January 11, 2025, 11:18pm UTC](https://community.open-emr.org/t/swagger-request-getting-401-response-after-registration/24269/2 "2025-01-11T23:18:57Z")

</div>

![102](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/8/f/8f4b568a6fc1cbdc68ce3557aae1ca94dc9ca9fc.png)

---

<div class="post-metadata">

**Author:** ![saeed](https://community.open-emr.org/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@saeed](https://community.open-emr.org/u/saeed)\
**Post date:** [January 11, 2025, 11:20pm UTC](https://community.open-emr.org/t/swagger-request-getting-401-response-after-registration/24269/3 "2025-01-11T23:20:03Z")

</div>

![103](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/d/e/def1ca12929b76608833a238dcec58675ab42a5b.png)

---

<div class="post-metadata">

**Author:** ![adunsulag](https://community.open-emr.org/user_avatar/community.open-emr.org/adunsulag/32/12606_2.png) [@adunsulag](https://community.open-emr.org/u/adunsulag)\
**Post date:** [January 12, 2025, 1:09am UTC](https://community.open-emr.org/t/swagger-request-getting-401-response-after-registration/24269/4 "2025-01-12T01:09:38Z")

</div>

Look at the scope parameter in your registration request. Your client is not requesting any access to the **user/patient.read scope** , I’ve moved your post to a different issue as your not getting invalid client but a 401 access denied response. If you turn on under Config in Logging the System Error Logging Options to Debug mode and you’ll get more details in your php error log of what you are doing wrong.

---

<div class="post-metadata">

**Author:** ![saeed](https://community.open-emr.org/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@saeed](https://community.open-emr.org/u/saeed)\
**Post date:** [January 12, 2025, 1:29am UTC](https://community.open-emr.org/t/swagger-request-getting-401-response-after-registration/24269/5 "2025-01-12T01:29:22Z")

</div>

Thank you.

Could you please let me know which one of the get or post items on swagger should work with this scope?

In addition, I have tried the full scope, but that gave another error which I will post here in an hour.

I did turn on the logging, If you could tell me where to find the log files I would appreciate it a lot. Thanks.

---

<div class="post-metadata">

**Author:** ![saeed](https://community.open-emr.org/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@saeed](https://community.open-emr.org/u/saeed)\
**Post date:** [January 12, 2025, 5:41am UTC](https://community.open-emr.org/t/swagger-request-getting-401-response-after-registration/24269/6 "2025-01-12T05:41:47Z")

</div>

I found this in the log files inside oauth2 folder

OpenEMR.ERROR: OpenEMR\Common\Auth\OpenIDConnect\Grant\CustomAuthCodeGrant-\>validateClient() client returned was not enabled

OpenEMR.ERROR: OpenEMR\Common\Auth\OpenIDConnect\Grant\CustomAuthCodeGrant-\>validateRedirectUri() Invalid client detected. Failed to validate redirect uri {“redirectUri”:“[https://emr-easy.com/swagger/oauth2-redirect.html",“client”:“h2mw7UT\_a1lRPVSrR0JK2RQIgzfRxLdgXv9zGXy7p2I”,“message”:"Client](https://emr-easy.com/swagger/oauth2-redirect.html%22,%22client%22:%22h2mw7UT_a1lRPVSrR0JK2RQIgzfRxLdgXv9zGXy7p2I%22,%22message%22:%22Client) authentication failed”,“trace”:“#0 /home/ddfvd6qhit7y/public\_html/vendor/league/oauth2-server/src/Grant/AbstractGrant.php(290): League\OAuth2\Server\Exception\OAuthServerException::invalidClient()\n#1 /home/ddfvd6qhit7y/public\_html/src/Common/Auth/OpenIDConnect/Grant/CustomAuthCodeGrant.php(101): League\OAuth2\Server\Grant\AbstractGrant-\>validateRedirectUri()\n#2 /home/ddfvd6qhit7y/public\_html/vendor/league/oauth2-server/src/Grant/AuthCodeGrant.php(281): OpenEMR\Common\Auth\OpenIDConnect\Grant\CustomAuthCodeGrant-\>validateRedirectUri()\n#3 /home/ddfvd6qhit7y/public\_html/src/Common/Auth/OpenIDConnect/Grant/CustomAuthCodeGrant.php(91): League\OAuth2\Server\Grant\AuthCodeGrant-\>validateAuthorizationRequest()\n#4 /home/ddfvd6qhit7y/public\_html/vendor/league/oauth2-server/src/AuthorizationServer.php(163): OpenEMR\Common\Auth\OpenIDConnect\Grant\CustomAuthCodeGrant-\>validateAuthorizationRequest()\n#5 /home/ddfvd6qhit7y/public\_html/src/RestControllers/AuthorizationController.php(504): League\OAuth2\Server\AuthorizationServer-\>validateAuthorizationRequest()\n#6 /home/ddfvd6qhit7y/public\_html/oauth2/authorize.php(86): OpenEMR\RestControllers\AuthorizationController-\>oauthAuthorizationFlow()\n#7 {main}”}

OpenEMR.ERROR: AuthorizationController-\>oauthAuthorizationFlow() OAuthServerException {“hint”:“”,“message”:“Client authentication failed”,“payload”:{“error”:“invalid\_client”,“error\_description”:“Client authentication failed”,“message”:“Client authentication failed”},“trace”:“#0 /home/ddfvd6qhit7y/public\_html/vendor/league/oauth2-server/src/Grant/AbstractGrant.php(290): League\OAuth2\Server\Exception\OAuthServerException::invalidClient()\n#1 /home/ddfvd6qhit7y/public\_html/src/Common/Auth/OpenIDConnect/Grant/CustomAuthCodeGrant.php(101): League\OAuth2\Server\Grant\AbstractGrant-\>validateRedirectUri()\n#2 /home/ddfvd6qhit7y/public\_html/vendor/league/oauth2-server/src/Grant/AuthCodeGrant.php(281): OpenEMR\Common\Auth\OpenIDConnect\Grant\CustomAuthCodeGrant-\>validateRedirectUri()\n#3 /home/ddfvd6qhit7y/public\_html/src/Common/Auth/OpenIDConnect/Grant/CustomAuthCodeGrant.php(91): League\OAuth2\Server\Grant\AuthCodeGrant-\>validateAuthorizationRequest()\n#4 /home/ddfvd6qhit7y/public\_html/vendor/league/oauth2-server/src/AuthorizationServer.php(163): OpenEMR\Common\Auth\OpenIDConnect\Grant\CustomAuthCodeGrant-\>validateAuthorizationRequest()\n#5 /home/ddfvd6qhit7y/public\_html/src/RestControllers/AuthorizationController.php(504): League\OAuth2\Server\AuthorizationServer-\>validateAuthorizationRequest()\n#6 /home/ddfvd6qhit7y/public\_html/oauth2/authorize.php(86): OpenEMR\RestControllers\AuthorizationController-\>oauthAuthorizationFlow()\n#7 {main}”,“redirectUri”:“”,“errorType”:“invalid\_client”}

---

<div class="post-metadata">

**Author:** ![alfa](https://community.open-emr.org/user_avatar/community.open-emr.org/alfa/32/21202_2.png) [@alfa](https://community.open-emr.org/u/alfa)\
**Post date:** [January 12, 2025, 9:37pm UTC](https://community.open-emr.org/t/swagger-request-getting-401-response-after-registration/24269/7 "2025-01-12T21:37:47Z")

</div>

Dear Saeed,  
TL/DR; Upgrade to Patch 3 over 7.0.2 and retry.

To describe more, I have found an issue on version 7.0.2 which might have affected you depending on the method you have used to install openemr.  
Actually, there ought to exist a _\_rest\_config.php_ file in the root of openemr folder as referenced by the line 22 of _register-app.php_ (as of version 7.0.2, and line 34 in the patch 3 as shown in the picture).

I confirm that the above file does not exist in release 7.0.2 (windows zip file). But it will be added if you apply patch3 (elaborated in the photo again). I have not yet investigated the packages for other platforms (e.g. the tar.gz version for linux, etc) for the same flaw.

Kindly please verify whether your “_openemr/interface/smart/register-app.php_” references the “_/openemr/\_rest\_config.php_” using “_require\_once(“./…/…/\_rest\_config.php”_);” syntax on the first few lines (probably 20 to 40) of the former mentioned file. Then kindly please verify existence of the latter mentioned file.

 ![rest_config](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/8/2/82bdef904e1457732c6484099e739483838ad3a3.jpeg)
