# Getting Error While Calling the Authorization Code Grant

**URL:** <https://community.open-emr.org/t/getting-error-while-calling-the-authorization-code-grant/16300>\
**Category:** OpenEMR Development\
**Created:** [March 19, 2021, 8:56am UTC](https://community.open-emr.org/t/getting-error-while-calling-the-authorization-code-grant/16300 "2021-03-19T08:56:59Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![mohit](https://community.open-emr.org/letter_avatar_proxy/v4/letter/m/c68b51/32.png) [@mohit](https://community.open-emr.org/u/mohit)\
**Post date:** [June 25, 2021, 10:05am UTC](https://community.open-emr.org/t/getting-error-while-calling-the-authorization-code-grant/16300/20 "2021-06-25T10:05:34Z")

</div>

Hi @adunsulag,  
I am successfully able to register client with API.  
For this i need to change some code in **src/RestControllers/AuthorizationController.php**  
At **configKeyPairs** function in private key with below code  
$keysConfig = [  
“config” =\> “D:/Xampp-7.3.20/php/extras/openssl/openssl.cnf”,  
‘private\_key\_bits’=\> 2048,  
‘default\_md’ =\> “sha256”,  
];  
$keys = \openssl\_pkey\_new($keysConfig);

Now for this i am able to register **oprivate.key** abd \*\*opublic.key \*\* in key table and not need to create file in **sites/document/certificate** folder.

But Can you help me one more thing  
When i try to get token by API **[http://openemr.localhost/oauth2/default/token](http://openemr.localhost/oauth2/default/token)**  
then it will give me error below: -  
**The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.**

 ![image](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/4/6/4604e0cd619f40091821939c787d4a2d147a4a06.png)

---

_[View the full topic](https://community.open-emr.org/t/getting-error-while-calling-the-authorization-code-grant/16300)._
