V6 Authorization and API changes afoot

Hi @jerry/@sjpadgett/@brady.miller,

I repeated my FHIR Api test at the instance https://demo.openemr.io.

Now when I call the FHIR patient Api (https://demo.openemr.io/openemr/apis/default/api/patient) i still get the 401 unauthorized error, but the error logged in the log file is different now.

Below is the extract of the error from the log file.

[15-Mar-2021 06:43:26 UTC] OpenEMR Error - api site error, so forced exit
[15-Mar-2021 06:46:27 UTC] OpenEMR Error - api site error, so forced exit
[15-Mar-2021 06:49:28 UTC] OpenEMR Error - api site error, so forced exit

I am also posting below the steps and related details I performed to get the access token.

1) Register
url: https://demo.openemr.io/openemr/oauth2/default/registration
post date:
{
“application_type”: “private”,
“redirect_uris”:[“https://client.example.org/callback”],
“post_logout_redirect_uris”: [“https://client.example.org/logout/callback”],
“client_name”: “FHIR Client”,
“token_endpoint_auth_method”: “client_secret_post”,
“contacts”: [“rmaurya@switchlane.com”],
“scope”: “api:fhir api:oemr openid”
}
Response:
{
“client_id”: “6Za3GjlERIyw5GM-ZXL6WjSqMUwITUdJ9ra_5br4R8g”,
“client_secret”: “Pv0GmUifie7vr5QqgJ-T7cEkiPKXblRSzQASmd7dPTR887fgjQ9jx_dP_tmO9qu8dfQgpl1Zi3OzefTyqFq-hA”,
“registration_access_token”: “IndIDVyC1xY77i_ypxQaTOqBKpXfBDiIRcEKV4w9FQ8”,
“registration_client_uri”: “https://demo.openemr.io/openemr/oauth2/default/client/VnS0mFWrRZOI830IURy3Gw”,
“client_id_issued_at”: 1615790537,
“client_secret_expires_at”: 0,
“client_role”: “user”,
“contacts”: [“rmaurya@switchlane.com”],
“application_type”: “private”,
“client_name”: “FHIR Client”,
“redirect_uris”: [“https://client.example.org/callback”],
“post_logout_redirect_uris”: [“https://client.example.org/logout/callback”],
“token_endpoint_auth_method”: “client_secret_post”,
“scope”: “api:fhir api:oemr openid”
}

2) Enable the API client

3) Authorize to get access code
url: https://demo.openemr.io/openemr/oauth2/default/authorize?response_type=code&client_id=6Za3GjlERIyw5GM-ZXL6WjSqMUwITUdJ9ra_5br4R8g&state=a95b970548dd8880ddb7c3192439f468fe63396f&scope=openid api:fhir api:oemr

scope confirmation:

Code Response:
https://client.example.org/callback?code=def5020044c5582138c51239881bc1f8695be369492672dfa2810a39af5a713fef9ed11b986d18879ec3a819b78a8772a3a6e92f62dd4fcd121b4c106774583bbcec8a5384d452f019bd68b9be07a59c3947ce558f9d2e9afed2f875408d1e469e1679c9d02f98756d3e44424a7817041d553be3b520135718e6f825a565a03d274e7ee19461197eeb04039cbeafb6d987aff16aee07fd5778a1565dc004d1ffbb3dcfb49722e832e67ea37298aa9a90e5894a0ad5461945aa7b4aaba7c78bd154786ef25544a01fa58cf01ee63d8b147550ab9dd7c59676e5677e76bb655936e5a18ebe10bc99abc5f90ed91921c995c89b6002929f63f350bb35344ffe821e306fa182d1a9e8529ef8c850a2513a31d150d720cd8892a73a015e5e391b4bde4c9d2027a1c229d4855e235ec0515aa8389604aaa4789c5543a4adb86ede5f797aa6656ab650589fd790fb7b82be11ba4a992a6f021abf509981be8f7f5d6277638a9801228f22c80ae4b6c44ca3dbed5bcf210c73d2a8251a549b0741f5efbd381adcc321307dbd17e774b905c747033583a0a70eef7039fefdee68fbb7e9e5202d2c9f54d7ea6f1e2fac4f&state=a95b970548dd8880ddb7c3192439f468fe63396f

4) Get Token
url: https://demo.openemr.io/openemr/oauth2/default/token
Post detail:

Response:
{
“id_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI2WmEzR2psRVJJeXc1R00tWlhMNldqU3FNVXdJVFVkSjlyYV81YnI0UjhnIiwiaXNzIjoiaHR0cHM6XC9cL2RlbW8ub3BlbmVtci5pb1wvb3BlbmVtclwvb2F1dGgyXC9kZWZhdWx0IiwiaWF0IjoxNjE1NzkyNTE3LCJleHAiOjE2MTU3OTYxMTcsInN1YiI6IjkyZjJhOWM1LTJmNDctNDVhZC1iMTU0LTg0ODhlNmU1MjMxMyIsImFwaTpmaGlyIjp0cnVlLCJhcGk6b2VtciI6dHJ1ZX0.BQOb3FWyTnYbzQ533jxLZf1B2E0LU4rOYJwA-FOMSrovExTXS1qvMNPiC8nivcJ7vatKKt2WIYjAm3YpNvaKbczkINoCvaIN20C0kKypKabhbtCgJkODjBqbx2TLehIp3wSLV_2jzaTT4qtLYl9wMoTDKso6AD9d99YuBopzFp6OaQcBvGdMOrMYZEfouWJZoFO9LG7vY2KylYJbAXFQu1TFSu1PNDnGsy8DhvYVP1XV5ziLvKzGDbqJI71lvPEdGa3dONc_8Rv1C0xORZT39oiafd61Cw2ai8rl4U6v_EkRhFNletwLfjSvnkdD-TCKqCxysHY5K4AQLkE2IOg_cA”,
“scope”: “openid”,
“token_type”: “Bearer”,
“expires_in”: 3600,
“access_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI2WmEzR2psRVJJeXc1R00tWlhMNldqU3FNVXdJVFVkSjlyYV81YnI0UjhnIiwianRpIjoiMDdjMWFlMTkxZWRhMmNmNzVhMTkyYmI1ODViZTYxZGQwZWIxMWM4YzU1ZWI3ZGUwM2U2ZGM1MDY2YjQ5NmM4MTM4YmJjOGUzOThiMjNkZjYiLCJpYXQiOjE2MTU3OTI1MTcsIm5iZiI6MTYxNTc5MjUxNywiZXhwIjoxNjE1Nzk2MTE3LCJzdWIiOiI5MmYyYTljNS0yZjQ3LTQ1YWQtYjE1NC04NDg4ZTZlNTIzMTMiLCJzY29wZXMiOlsib3BlbmlkIiwiYXBpOmZoaXIiLCJhcGk6b2VtciIsInNpdGU6ZGVmYXVsdCJdfQ.EmhOBYtcSvIiGvITn5y0bu0Ovd6XYkSb5Su11Y5dJjK2OkODfnFlssMHs3rVkPgrVWjgRktMDil5SE96xbCr16P8KN4ER38y7pcxp0wz1CXOFmJdE_e4fs3WtzE89tbgoiP_Eo0aMn-8osolANXM3sx3q-F30pQZkRnZwkj5bRoxv9JtTArYFD6ZPO60bkj_PMGS3nfNk-DewI0ST_P-9xOOi2IV2hUijTsmxDlEQahadhFdcqgmz4qgVQtP-cWVKH2x3a39icTCJyrYoUnmfSKcSLMYLepeipzkdt5XiDZsDmzPP-1LGlRGw6uqnKOmcxbD2qYrJ0Ub7RAuGijRvg”,
“refresh_token”: “def502004bd5669df42a6c8357edae5faba4b49a8e3ce0ec7a2a59e2a20b6edbbe589572ce3d3ee4259b4bbe16b78477a6ea1e0d01b6e7c0309a75682e3ad18baac6aa2c7c073831e81828cd1a4454616658a50071622d9d207508ef23456429c50dd3d7f2513a2d9ad83d7a34ffd3b2953f8fc3ab401b3702671521767e94e3f3326367e630849086625c540947414000eaaf83bb7f69309d5349c5d38818b027802e7235db0f5ca4a108de6dade6b992ccd9b97de853c601d79baccd144bb854ee73d29140bf7cd9e9218addc969f75e8a8b342a3192d1a04888b6d36aedc0256b2ff05977501ed6b14b961c5eb5e0fdbfaeded7935ae7749b33d8ced1b45bc26ca9b6a06548570d4e84d942850f722cc755a44f6db6f2e664954114f1b315bf161951e44591e9d18566a8489c06110ad84fe51a528791c6b43e0bb0bdb3fbdd5d14ed043c66a70b5c90e4da40eb19778be9816256ecbf23de96dcb249220dd04739e89e43256fcf19bac69dbffb0a6688b6dcb4769a9e1612f645b4f2a54c093e9c7510bbcc80a980eabc46ec17ef2f95e261ca4d81560d1f1d3ec0059f2deaf78695caf841593e8cf697a25a7d61b49693a8ef7a411a19402694bb9533bfe6ac89a6cc87d9b9db0cd6299ebb14fc9c07acc7c0da3021851b8a261f”
}

  1. FHIR Patient API access - with “access_token” as bearer token
    Url: https://demo.openemr.io/openemr/apis/default/fhir/Patient
    Response: 401 unauthorized

  2. API patient access - - with “access_token” as bearer token
    Url: https://demo.openemr.io/openemr/apis/default/api/patient
    Response: 401 unauthorized

Please let me know how we can access the FHIR Api using the Oauth2 access token.

Thanks,

Rajesh Maurya