SMS text with ring central

It means you’re not logged in to RC.
Did you get a oauth dialog? You should get a log in button next to refresh when you get that error also.
Hope you didn’t use the exact redirect url I showed as that’s for my server. You have to replace my domain with yours. Also, that same url has to be setup in your RC account settings. App needs to have Auth Code and Refresh Token set.


You need to be sure you’re on the 2.2.0-dev version. If you upgraded openemr to v6 then you need to reinstall faxsms for v6 version. Also try to Disable click trash can then go to unregistered to reinstall the setup. Do this too if you decide to reinstall from composer ie do trash can the composer install.

Can you reach setup from the Fax UI Action->Account Credentials

Yes i’m on version 6, so i will go and get the faxsms for that version and give it a try

Are you going to install with composer?

Thinking about it I wonder if an account is setup for password it may still work w/o oauth login. i.e. same as earlier version of module. R.C forces a more rigorous turn up for server password which is why I changed over to Auth code grant. It should work for legacy password grant but most folks already have a RC account where you don’t have to setup production testing with RC.

Do you have the link to the thread for the fax module for V6?

openemr/oe-module-faxsms: Fax and SMS feature for OpenEMR
Do with composer install. Not sure about using the download, never tried but may be okay.

You must install via composer because I haven’t released the dev version yet so download gives old code…
composer require “openemr/oe-module-faxsms:2.2.0-beta”

Just checked and you can download from

I get the page to authorize the app but when I select authorize the dialog box/window disappears.

Sherwin can you just give me a call now to go through this. I’m not up for all the typing…

@sjpadgett, finding where the system changes the session did not take long. The moment the authorize button is selected the system loads a new session and the multi site session is lost. The system returns to default as the session ID. I turned on the debug in the globals to alert when the session change.

I checked when the rcauth.php page loads the session site id is set to the multi site that I am logged into.

The thing that came to mind to solve this is to drop a session cookie. Retrieve the cookie to see if it matches the site id of the new session if it does not match use the cookie site id.

@juggernautsei
Nope, just add ?site=yoursite to the redirect urls i.e ....rcauth.php?site=multisite
that’ll fix it…

That works but the platform.json file is still not being created.

Did you get this figured out. I’m still trying to decide if I want to move the token to database.

No, I have not figure it out yet. I will be working on this again in the evening.

@sjpadgett

I am trying my best to unwravel this logic

    $this->rcsdk = new SDK($this->credentials['appKey'], $this->credentials['appSecret'], $this->serverUrl, 'OpenEMR SMS', '1.0.0');
    $this->platform = $this->rcsdk->platform();
    $authback = $this->cacheDir . DIRECTORY_SEPARATOR . 'platform.json';
    $cachedAuth = array();
    // May use stored auth tokens that may not have expired
    // from last api use. Refresh tokens life is 7 days.
    // Access tokens are 1 hour. sic.. give me a break.

file exist is used to see if there is an existing json file. So, here you are getting the contents of the existing file and then deleting the existing file. And I know this happens because if i manually create the file and run the auth. The file gets deleted.

   if (file_exists($authback)) { 
        // stored tokens may be expired but, will try em anyway.
        // anything but a ridiculous log in!
        $cachedAuth = file_get_contents($authback);
        $cachedAuth = json_decode($this->crypto->decryptStandard($cachedAuth), true);
        // delete will update with current auth.
        unlink($authback);
    }

We know that if line 197 is commented out the process drops through. So that means that the platform refresh is not happening. Is that logic correct?

So the system sends us to the login page and then we log into the RC portal. And then it prompts us to authorize the app.

Line 31 of the rcauth.php the system is looking to get the contents of a file that does not exist. _credentials.php

Ok, there is an error in the rcauth page. I am tracking it down but the script is not making it down to where the file is written to the folder.

Here is my latest error message

Error log

 [Thu Feb 25 19:55:27.850061 2021] [php7:error] [pid 269863] [client 70.184.171.187:59076] PHP Fatal error:  Uncaught GuzzleHttp\\Exception\\ClientException: Client error: `POST https://platform.devtest.ringcentral.com/restapi/oauth/token` resulted in a `400 Bad Request` response:\n{\n  "error" : "invalid_redirect_uri",\n  "errors" : [ {\n    "errorCode" : "OAU-109",\n    "message" : "Redirect URIs do no (truncated...)\n in /var/www/html/boss/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113\nStack trace:\n#0 /var/www/html/boss/vendor/guzzlehttp/guzzle/src/Middleware.php(69): GuzzleHttp\\Exception\\RequestException::create()\n#1 /var/www/html/boss/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}()\n#2 /var/www/html/boss/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\\Promise\\Promise::callHandler()\n#3 /var/www/html/boss/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\\Promise\\Promise::GuzzleHttp\\Promise\\{closure}()\n#4 /var/www/html/boss/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\\Promise\\TaskQueue->run()\n#5 /var/www/html/boss/vendor/g in /var/www/html/boss/vendor/ringcentral/ringcentral-php/src/Http/Client.php on line 52, referer: https://login.devtest.ringcentral.com/?responseType=code&clientId=-TXw9k_cT26UfnR13Uj_fQ&brandId=1210&state=login&localeId=en_US&endpointId=&session=7734735640127210740&display=page&prompt=login%20sso&scope=&appUrlScheme=https%3A%2F%2Fehr.medbossconsulting.com%2Finterface%2Fmodules%2Fcustom_modules%2Foe-module-faxsms%2Frcauth.php%3Fsite%3Dserenity&ui_options=&code_challenge=&code_challenge_method=&hideNavigationBar=true

no. if we get to L-197 it means we don’t have a login session with RC so return 0 will cause rcauth to be called from messageUI.

The deleted token file is by design because it gets repopulated with new access token from a refresh token. If file is not there then you don’t have valid tokens or login.

Are you sure the Production flag is not set in setup ui?

Also be sure your RC account has these minimum permissions!

Once I created the _credentials.php file. The system creates the platform.json file.

You don’t need that credential file. It’s there for legacy upgrades. Because platform/json is created doesn’t mean it has valid token…

You shouldn’t have to do anything. Existing code is fine best I can tell. I’ve create a multisite and tested fine.
Only worry if platform.json is there after completing oauth. Otherwise don’t worry because code takes care of refresh.

Are you working now?

No, I did not work on this last night. I am waiting on testing. Sometimes what we intend for code to do is not what it does. Or sometimes I have learned there is a side benefit or effect that was not anticipated.

With that said, the .json file did not show up until I included the _credential file.
I had to add the Read Call Log and that error message that I posted went away. So, I think we are ready to do some more testing.

Tested and fax may have gone out. But all errors are gone and it looks functional. I have received and system SMS

Troublesome for sure Sherwin. That block of code is simply no longer needed and was put there for old version where I stored account data in cache.
If credential file doesn’t exist, routine simply creates and returns an empty credential array and the new account info is generated and stored to database from setup UI.

So in order for this not to work, file_get_contents would have to return something other than false on a non exist credential file in cache. All recent versions of PHP will return false in this case so, your case is a fluke. Because if it wasn’t working, you’d never have been able to input your account info.

Bottom line, the platform cache file will only get created if you have a valid login and gets deleted and regenerated on each new access token from a refresh token. Most time user only needs to login once and could be months before having to log back into RC.

Since legacy is no longer needed, i’m removing that chunk of code.