SMS text with ring central

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.

We are mostly working. There is no a credential issue that has popped up today. I will deal with that tomorrow. (Monday)

I’m rewriting that section so i’ll post another patch later…

1 Like

To all
For new installs, recm a composer install.

New release where I added some better credential hook error traps

@juggernautsei
Give me a call and i’ll explain how I added event listeners for a sendSMS dialog button you can put in strategic places if you want user to be able to send messages. Maybe appointment dialog.

Check out comments in: interface/modules/custom_modules/oe-module-faxsms/openemr.bootstrap.php

Install this patch first so you can get the changes for v6 patch 1 that supports faxsms:


Then download from repository released version at:

This is working very well for me. I’ve installed, reinstalled, tested multisite etc. So good luck.
Jerry out. :slight_smile:

1 Like

Hi @sjpadgett
I copied the new code into the directory.
However, when this screen comes up to log in. It shows this.
On this screen, we are using the same login that we would use to log into the RC account as we did before. What login credentials should we be using on this page?

The main RC Admin account portal credentials are different that the sandbox credential(well usually) as it’s a different acct.

Use your sandbox credentials. Most likely the same as your fax/sms account credentials ie Username and password. This throws me sometimes too. oh be sure Production isn’t checked…

You got it! We are connected now. Going try sending a fax.Thanks! You da man!

ya see, Air Force and Navy vets can work together!:slight_smile:
Thanks for your service even if Navy.:slight_smile:

Also you will notice sending a fax to your sandbox account will likely only show the cover sheet!

You got jokes :sunglasses:

I am looking at those SMS event listeners that you put in the openemr.bootstrap file. I am going to try one out and put it in the calendar section.

Remember to setup your dialog for smsSend() to accept a phone number. You could also add a fetch to grab patient data from pid to the dialog if phone is not available in calendar event(this is what i’ll add to the default listener soon). Or pass from a fetch inside calendar code or and or …

1 Like

Any idea what could cause this message when logging in? i have verified the account credentials, the client secret and client ID

Error: Authentication Service Denies Access. Get Pending