Hello,
I’m struggling a bit with an Oauth2 implementation. I’ve been trying to follow the example laid out here:
What works:
I can pop open the Oauth2 dialogue with the required parameters and I can click the Authorize button. A request with an authorization code is then sent to my server per the specified redirect_uri parameter.
Where I’m stuck:
Once my server gets the authorization code, it tries to make the following request to get access and refresh tokens. However, it’s failing with a 400.
Here’s log output which shows request/response headers, parameters and bodies etc.
POST https://emr-test.mphise.us/oauth2/default/token
Content-Type application/x-www-form-urlencoded
Accept application/json
{grant_type=[authorization_code], client_id=[kF478EdEQo-IFv0vze_zPWtZ6Qfb6sW9ZeGq9o4l19g], client_secret=[LITal0M7Y5iwEIinB_75hL776ITeF8o7P41TF0fEZurYs_**** omitted ****], code=[def502000951abacd87f202bc469c3420b22d9a5c2e8683946c989bc8367901200155b18c492284637b42d6eb8453a777b8eb869d3693257193c5afba9358aa6a23573d1a6f0536b8aac43d4fde20b3a37d67eeb245c4b77a3db5c73b5d7c194c3b5407f60f24278f39edd9662f37fdbd3f02f60b6ddc84154e623e399ee41de0aa7aee210f6901e5c1f33211a3c6666e2d77ac192cbf7e062d3f0d6ea2945dd221b4733fb4b83e99cf58db5aba318355861d54c761e10e27605c5cc13dd96ad071053f9a70fa22303b1008207d93153209784545962e5b5b102694386b439d1a6068296588beeeeed6e0a4251b7e0b2753b2de60b6a0dcb3237feedcd70eb64c7c0f639e54d1c94c9d6d815dc2fbd3e5cfe443ddf6853ab3bb97d03772c2704a9031ad471a536cc2ad363ff54c8c5d476ea3021284fd8a9de44396704b74bd8aebe5eff9a45a8cfb0ba3fae151415091b65ce309b817d85018685f47c8a21d8e6291f553218c40e895e924c700654327dc6e2bcbe633794dc3525d2673916bbd86834d7c2966369c3be27d782dd7ca1aa1f9e018df0fa086589b3d417f7173384dd5e361e9419a07f13ebe8bffe0b397354573891da83f0520bb8684d718e78f22209bfe14d23217f9480b6d68d79a71d7ac3a3879485da3fa93aa40f07774c4c82eed26ade29ffabac6ebdf0cfd7d360c114b30cf7db0f0f17be9a92be9cd573ea01d79a2872dc293f26311bdbce0ea23e11cbbe7bd1c069376911a1997f5881ef0d4aaff1f6c028a7b3fa8dd4fce737abb4a086194c9c09b7946489e8249f6f640bcd4cf693c94c3c88a1b279f89feb7616fd61f067993bf93fbbf03bc50a0e443524f58057a9639170534b884104a4e0ca8fa7831ffdae3757032987e7b3013309d194849864184336ebf9b3e102f0ad7afe82f804d9f19d02e333c824d257d549aebaaf5ea0398142b497f8d26769e203afcfd0412b7931abfbd4a1b6511d5ecdabc1ee6a934af6d03eaad5392843e58495cd5c8c879a785d576ee0b48eedc095a29656c29153a7cf7ff0e00b5ab48a30c51f74298b89622b27cbdfe3c1523c469287dcc270e7a62e796595ef5d3d57b9574281c52716fc42101f5911d3870422c581da361be3de03169bc241d638ef824dcd178c2198122e10af90b6585347b15d0e7c04f8d7862506e7e319253824521a0933bc24532364cfbc1f7d3a40c0571c8affd0ffdb49523fe827e4b1d78e750371b6a3f13b2d9a2c47f5362d7e8083f9f80d040d2ad537785c270ccc3ccb8d43e5783525181e73d528fb2bf1930b823937c510b4d116f6cbf543ae2eb2efa04a2433882722c4545c292bb0c2ba640fb82162ff8d73fc5b2dd554f001980de6dce3401e36a2b83a4b3fea87315af9e7789d92f6281807bebf4d639c05581fa443750af2636cc34bfdc7e140ed3c3e04430e3c84f5bee296419a2f446475288be8ce9896c6a40a356110512aa2f409ba3c815e9af0b3f5e7cc80ac60b2d69f222ad29b23b1d9f5c806721109e1c3651dbf70e5be24d8ad1df5bcc6cfa0ca5aa58a9df21323ee566bc3c8fa7799caab6c6db90a4a09ec77a23dbef9a271e1636887bd2ca02a19e2d60ccabd54fae632dd7e3fbdefd1f8f382f4feaa86006ce9d79905fb861d96e16f594572f01412c38b605faa1dd46cb53c19b1ae0e124cc3bab1bec9f20a527b94e4798a1568653df572a2baf0d9fb91bd10fd9f62587aa305cf9c7652b9a6feba59306d7047eb5309f641453b7ee70c4228ca7b1a80af3f7c2ea896b189afbec0463742c12de4aba15f7ba427c6a000b6b35f2c6f116a77f6d9f128cdb76c3e6cc7e0341f1d6b79b07a9a5d7cdbd47998fab1880421aa1e4bc4373cd5fdb6f4f828244bd8cc6298ef70c01541ed210e83b74d5c20ff7a5337c5dae58374dcded33bdf1756ca6c1a7cae60746c2f0f552d7d8030ae8185427679935af8456bc68afac53b667fd6782409e8b2b0975cbec2835bb691fe277f7658257175c4248f9f96a3160466c7c81283543c0c2fc4d66a906c2a175b361832c3997a80]}
400/Bad Request
Date: Tue, 15 Mar 2022 03:43:38 GMT
Content-Type: application/json
Content-Length: 85
Connection: keep-alive
Server: Apache
Set-Cookie: authserverOpenEMR=WwPfhCZRZa8m%2CCyDps2nfV2E6Gu%2CU44de-ce5dcQmVq9RrWq; expires=Tue, 15-Mar-2022 11:30:18 GMT; Max-Age=28000; path=/oauth2/; secure; HttpOnly; SameSite=None,authserverOpenEMR=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/oauth2/; secure; HttpOnly; SameSite=None
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: origin, authorization, accept, content-type, x-requested-with
Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-XSS-Protection: 1; mode=block
{“error”:“invalid_request”,“error_description”:“Bad request”,“message”:“Bad request”}
I’m unfortunately stumped. Is there something wrong with my POST request to /oauth2/default/token?
Thank you,
Chris