web stats
Issue getting a response from Security Token Service - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-13-2018, 12:06 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default Issue getting a response from Security Token Service

I'm trying to use Mirth to connect to an STS to retrieve a JSON web token however I have been unsuccessful in doing so and only get a HTTP/1.1 500 Internal Server Error returned.

When I try the interaction using Postman or curl I get a response just fine:

e.g.

Code:
[root@HVLNXMRTHT01 ~]# curl -X POST -G 'https://85.91.40.18:443/csp/healthshare/ldppatients/passthrough/EnsLib.REST.GenericService.cls' -d CfgItem=RestPassThrough -H 'Authorization: LHCIE-JWT eyJTdWJqZWN0SUQiOiJFU1RIIFN5c3RlbSBBY2NvdW50IiwiU3ViamVjdE9yZ2FuaXphdGlvbiI6IkVwc29tIGFuZCBTdCBIZWxpZXIgTkhTIFRydXN0IiwiU3ViamVjdE9yZ2FuaXphdGlvbklEIjoiMS4yLjMuNCIsIlN1YmplY3RSb2xlIjoiMi4xNi44NDAuMS4xMTM4ODMuMi4xLjMuNDYuMi4xLjEuMi4xLjIuNyIsIlB1cnBvc2VPZlVzZSI6IjIuMTYuODQwLjEuMTEzODgzLjIuMS4zLjQ2LjEuNS4xMDEifQ' -H 'Content-Type: application/x-www-form-urlencoded' -k
{"access_token":"eyJ0eXAiOiJJVUEtSldUIiwia2lkIjoiRU1BSUxBRERSRVNTPW1hc3NpbWlsaWFuby5tYXNpQHRpYW5pLXNwaXJpdC5jb20sIENOPXNlcnZlcjEsIE9VPURlbW8gRW52aXJvbm1lbnQsIE89VGlhbmkgU3Bpcml0IEdtYkgsIFNUPUF1c3RyaWEsIEM9QVQiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJ1cm46b2lkOjIuMTYuODQwLjEuMTEzODgzLjIuMS4zLjQ2LjIuMS4xLjEuMS41LjEiLCJzdWIiOm51bGwsImF1ZCI6Imh0d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Fq-Vf53fs-3pCwRbKHzFULXV8scUg0Bz7_3O8a3W04eScM0w","token_type":"IHE-JWT"}

I have attached the channel and a full description in the hope that somebody may spot what may be the issue.
Reply With Quote
  #2  
Old 04-13-2018, 02:15 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

Hmm I think your problem is here

Code:
channelMap.put('jsonclaim',jsonclaimstring);
//var encodedclaim = FileUtil.encode(new java.lang.String(jsonclaimstring).getBytes());
var urlsafeencoder = Packages.java.util.Base64.getUrlEncoder();
var encodedclaim = urlsafeencoder.withoutPadding().encodeToString(new java.lang.String(jsonclaimstring).getBytes());
channelMap.put('encodedjsonclaim',encodedclaim);
Are you trying to base64 encode the JSON Claim and send it to the API? or you are trying to URI encode it? Because those two are seperate. Below is how I URI encode using a JS function.

Code:
//Converts your refreshToken to a URI encoded format, essentially replacing special characters.
    encodedtoken = encodeURIComponent(refreshToken);
__________________
HL7v2.7 Certified Control Specialist!
Reply With Quote
  #3  
Old 04-13-2018, 03:04 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

Thank you for looking at this and appreciate your input but I have already verified that the base64 encoded claim copied from the output that my code is giving in Mirth and pasted into the curl command, and on Postman, works, and returns a response when these methods are used.

Here is what Mirth has generated and is sending:

Code:
URL: https://85.91.40.18:443/csp/healthshare/ldppatients/passthrough/EnsLib.REST.GenericService.cls
METHOD: POST

[HEADERS]
Authorization: LHCIE-JWT eyJTdWJqZWN0SUQiOiJFU1RIIFN5c3RlbSBBY2NvdW50IiwiU3ViamVjdE9yZ2FuaXphdGlvbiI6IkVwc29tIGFuZCBTdCBIZWxpZXIgTkhTIFRydXN0IiwiU3ViamVjdE9yZ2FuaXphdGlvbklEIjoiMS4yLjMuNCIsIlN1YmplY3RSb2xlIjoiMi4xNi44NDAuMS4xMTM4ODMuMi4xLjMuNDYuMi4xLjEuMi4xLjIuNyIsIlB1cnBvc2VPZlVzZSI6IjIuMTYuODQwLjEuMTEzODgzLjIuMS4zLjQ2LjEuNS4xMDEifQ

[PARAMETERS]
CfgItem: RestPassThrough

[CONTENT]
Same header in the curl command:


Code:
curl -X POST -G 'https://85.91.40.18:443/csp/healthshare/ldppatients/passthrough/EnsLib.REST.GenericService.cls' \
-d CfgItem=RestPassThrough \
-H 'Authorization: LHCIE-JWT eyJTdWJqZWN0SUQiOiJFU1RIIFN5c3RlbSBBY2NvdW50IiwiU3ViamVjdE9yZ2FuaXphdGlvbiI6IkVwc29tIGFuZCBTdCBIZWxpZXIgTkhTIFRydXN0IiwiU3ViamVjdE9yZ2FuaXphdGlvbklEIjoiMS4yLjMuNCIsIlN1YmplY3RSb2xlIjoiMi4xNi44NDAuMS4xMTM4ODMuMi4xLjMuNDYuMi4xLjEuMi4xLjIuNyIsIlB1cnBvc2VPZlVzZSI6IjIuMTYuODQwLjEuMTEzODgzLjIuMS4zLjQ2LjEuNS4xMDEifQ' \
-H 'Content-Type: application/x-www-form-urlencoded' -k

Last edited by seaston; 04-13-2018 at 03:20 AM.
Reply With Quote
  #4  
Old 04-13-2018, 09:13 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 841
agermano is on a distinguished road
Default

Do you have to add the Content-Type: application/x-www-form-urlencoded header in mirth?
Reply With Quote
  #5  
Old 04-13-2018, 09:23 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

I believe so. That is what their specification says and I have added the same in the curl command which works. If I change it in Mirth then I have to put something in the body and that does not work either. I've tried it.
Reply With Quote
  #6  
Old 04-13-2018, 09:29 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 841
agermano is on a distinguished road
Default

I asked because it wasn't showing it in your mirth output, but it was in your curl command.
Reply With Quote
  #7  
Old 04-13-2018, 09:42 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

Thank you for looking at this but it is definitely set in the destination form for the http sender as content type application/x-www-form-urlencoded. As far as I can see all the settings match, and I have tried the curl from the same server as the Mirth service is running on, but the response it gets back are different. Completely stuck with this.
Reply With Quote
  #8  
Old 04-13-2018, 09:45 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

I added this as a header as well in Mirth (seem to be two places you could put this)

Code:
URL: https://85.91.40.18:443/csp/healthsh...ricService.cls
METHOD: POST

[HEADERS]
Authorization: LHCIE-JWT eyJTdWJqZWN0SUQiOiJFU1RIIFN5c3RlbSBBY2NvdW50IiwiU3ViamVjdE9yZ2FuaXphdGlvbiI6IkVwc29tIGFuZCBTdCBIZWxpZXIgTkhTIFRydXN0IiwiU3ViamVjdE9yZ2FuaXphdGlvbklEIjoiMS4yLjMuNCIsIlN1YmplY3RSb2xlIjoiMi4xNi44NDAuMS4xMTM4ODMuMi4xLjMuNDYuMi4xLjEuMi4xLjIuNyIsIlB1cnBvc2VPZlVzZSI6IjIuMTYuODQwLjEuMTEzODgzLjIuMS4zLjQ2LjEuNS4xMDEifQ
Content-Type: application/x-www-form-urlencoded

[PARAMETERS]
CfgItem: RestPassThrough

[CONTENT]
I still get this back though so it makes no difference:

Code:
<html>
    <head>
        <title>Error</title>
    </head>
    <body>Internal Server Error</body>
</html>
Reply With Quote
  #9  
Old 04-13-2018, 10:12 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

This is a puzzler. Maybe we are missing something in the fine print. Can you attach a POSTMAN collection of the same call, one that works.
__________________
HL7v2.7 Certified Control Specialist!
Reply With Quote
  #10  
Old 04-13-2018, 11:59 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

I've attached the postman json export file as a .txt below. It contains the post that works and returns a response that I need to get the mirth channel to do.
Attached Files
File Type: txt STS Collection.postman_collection.txt (1.4 KB, 10 views)
Reply With Quote
Reply

Tags
jwt, querystring, sts, urlencoded

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:16 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation