You do a registration request to: https://localhost/oauth2/default/registration
Next step is to authorize to: https://localhost/openemrv6/oauth2/default/authorize
The API docs says to use this url: https://localhost/oauth2/default and no example.
So I registered the admin account as an API client that worked fine.
I then proceed to authorize the client via a GET/POST to: https://localhost:443/oauth2/default/authorize using these params:
<br />
<b>Notice</b>: Key file "file:///var/www/localhost/htdocs/openemr/sites/default/documents/certificates/oaprivate.key" permissions are not correct, recommend changing to 600 or 660 instead of 700 in <b>/var/www/localhost/htdocs/openemr/vendor/league/oauth2-server/src/CryptKey.php</b> on line <b>63</b><br />
{
"error": "unsupported_grant_type",
"error_description": "The authorization grant type is not supported by the authorization server.",
"hint": "Check that all required parameters have been provided",
"message": "The authorization grant type is not supported by the authorization server."
}
Changing permissions on that file does nothing, this is where Iām stuck at the moment so Iām not sure if itās something Iām doing wrong or missing info in the API docs.
Iāve changed response_type to every response type supported based on: https://localhost/oauth2/default/.well-known/openid-configuration and get the same error.
Using the endpoint in the API docs https://localhost:443/oauth2/default doesnāt return anything but a 200 ok with an empty body.
Iām just looking to be able to use the API with the user accounts created in OEMR like it was prior to V6 since Iām just using OEMR as the backend of my app.
Used the access token from the previous request as the Bearer token for my next request to: https://localhost:443/apis/default/api/facility which then returns:
{
"error": "access_denied",
"error_description": "The resource owner or authorization server denied the request.",
"hint": "Error while decoding from JSON",
"message": "The resource owner or authorization server denied the request."
}
Regarding the Authorization Code Grant, that is done via a oauth2 standard flow. Thatās why the instructions are minimal (ie. use a oauth2 client, which I detailed an example of using one in the 4 steps several posts above) since there is a standardized process/flow for this (can learn about via google).
Regarding your password grant, just need to include the needed scopes in your scope on the client registration and password grant request. For example, the user/facility.read scope will get your call to https://localhost:443/apis/default/api/facility to work.
I was under the assumption that using api:oemr could grant access to all scopes under it the same for api:fhir etc. is that not the case?
I can register fine with all scopes but when I try to refresh the token with all scopes I get an invalid scope error.
<br />
<b>Notice</b>: Key file "file:///var/www/localhost/htdocs/openemr/sites/default/documents/certificates/oaprivate.key" permissions are not correct, recommend changing to 600 or 660 instead of 700 in <b>/var/www/localhost/htdocs/openemr/vendor/league/oauth2-server/src/CryptKey.php</b> on line <b>63</b><br />
{
"error": "invalid_scope",
"error_description": "The requested scope is invalid, unknown, or malformed",
"hint": "Check the `user/Coverage.read` scope",
"message": "The requested scope is invalid, unknown, or malformed"
}
Iāve tried escaping / and periods but no matter what I always get this error when trying to refresh the token.
From experience, the scope of the resource must be clearly specified at the time of registering and authorize. In your example, add user/Coverage.read to your scope.
Hi @benmarte ,
The user/Coverage.read scope is only in master (ie. dev version) since it was just recently added. If you are using 6.0.0, then it will fail if try to use that scope since it does not exist there. If doing shotgun approach on scopes (ie. including them all) while getting them to work and testing them out, then would use the listing of scopes in the API_README.md file included in the instance you are running from to avoid trying to use scopes that do not yet exists there.
Benjamin, Poor Soul here! Very helpful! I followed your instructions and Iām getting an error unsupported grant type? And unable to get the token response. Any thoughts Iām passing in āpasswordā into the value.
Cheers