JSON.parse: unexpected character at line 1 column 1 of the JSON data
means that the server is responding with something that is NOT JSON, but the browser (or JavaScript) is trying to parse it as JSON.
ROOT CAUSE IN YOUR CASE:
You’re using invalid entries for App Redirect URI and App Launch URI:
You entered:
App Redirect URI: Swagger UI
App Launch URI: Swagger UI: OAuth2 Redirect
These are not valid URLs, so when OpenEMR tries to process and return a response, it either:
Fails internally and returns an HTML/PHP error
Or outputs blank/HTML instead of JSON
THE FIX: Use Valid URLs (Demo Site)
Here is the correct way to fill out the form when registering an app for testing on the OpenEMR demo site https://seven.openemr.io:
Field
Correct Value
App Name
Swagger Test App
App Redirect URI
https://seven.openemr.io/swagger/oauth2-redirect.html
App Launch URI
https://seven.openemr.io/swagger/index.html
JSON Web Key URI
(Leave blank) unless you know what you’re doing with JWT keysets
App Type
Public or Confidential depending on if you want client_secret or not
Grant Type
authorization_code
Then submit the form.
How to Confirm It Works
Once submitted successfully:
Open Swagger UI at
https://seven.openemr.io/swagger/
Click “Authorize” (top-right lock icon)
Use your client ID (retrieved from DB or form) and try the OAuth2 flow
STILL GETTING THE ERROR?
Here’s how to debug it further:
Option 1: Browser Dev Tools
Press F12 → Go to Network Tab
Click the request for the form submit
Look at the Response tab
If it’s HTML, it’s a PHP error (e.g. Fatal error, undefined index, etc.)
If it’s blank, OpenEMR may have silently failed
Option 2: Check PHP Logs (on your dev site)
Check your file:
/var/log/php_error.log
Or OpenEMR’s log:
sites/default/logs/php_error.log
Summary
Don’t use plain words like “Swagger UI” in URI fields
Use valid HTTPS URLs (e.g. the Swagger redirect page)
Check Network & PHP logs if errors persist
Use:
Redirect URI → https://seven.openemr.io/swagger/oauth2-redirect.html
Launch URI → https://seven.openemr.io/swagger/index.html
Let me know if you want a working demo or want to register it via the database directly. I can help with that too. It will work