This is the first time our COBOL CICS team has attempted to obtain an OAuth Access Token. We have been at this for some time have asked a number of colleagues from various disciplines for advice but to date have this (hopefully) one last step which we just cannot get past. Hoping someone has had experience of this kind of integration and can provide some suggestions.
We are struggling to obtain a successful OAuth access token response from a COBOL CICS program. We receive a successful response form Postman, but when we try the call in our Web Converse we receive a HTTP 400 (Bad Syntax) response:
x3.1 CICS-RESP = 0000000000
HTTP-RESP 00400
HTTP error { "error_description" : "grant_type is required"
We are building the OAuth as per below. Note the "grant-type" is converted to "grant_type" when the JSON is constructed.
MOVE 1 TO grant-type-num
MOVE 'client_credentials' TO grant-type
MOVE 1 TO client-id-num
MOVE 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
TO client-id
MOVE 1 TO client-secret-num
MOVE 'xxxxxx-xxxxx' TO client-secret.
Our program then fails in the CICS WEB CONVERSE, where it cannot seem to hit the OAuth service:
EXEC CICS GET CONTAINER('JWT-JSON')
CHANNEL(WS-CHANNELNAME)
INTO(W01-MESSAGE)
RESP(CICS-RESP)
RESP2(CICS-RESP2)
END-EXEC
DISPLAY "W03-Message" W01-MESSAGE
MOVE 256 TO STATUSLEN
EXEC CICS WEB CONVERSE
URIMAP('FXJWTCLR')
POST
NONE
CLOSE
MEDIATYPE(CONTENT-TYPE-H)
CHANNEL(WS-CHANNELNAME)
CONTAINER('JWT-JSON')
TOCHANNEL(WS-CHANNELNAME)
TOCONTAINER('JWT-RESPONSE')
RESP(CICS-RESP)
RESP2(CICS-RESP2)
SESSTOKEN(TOKEN)
STATUSCODE(HTTP-RESP)
STATUSTEXT(STATUSTEXT)
STATUSLEN(STATUSLEN)
END-EXEC.
We receive the "grant_type is required" even though we are passing grant type in my program and converting the COBOL data to JSON before calling WEB CONVERSE. To be clear here is snippet of code where we compile the JSON:
EXEC CICS TRANSFORM DATATOJSON
CHANNEL(WS-CHANNELNAME)
INCONTAINER('JWT-TOKEN')
OUTCONTAINER('JWT-JSON')
TRANSFORMER('FXJWT')
RESP(CICS-RESP)
RESP2(CICS-RESP2)
END-EXEC.
If we create the JSON manually ad pass to Postman, it seems to work fine.
not sure if we have shared sufficient code snippets here?