Its crashing in both these version.  Many Thanks.  Paul.

Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2017.2.1 (Build 801U) Wed Dec 6 2017 09:23:15 EST [HealthShare Modules:Core:16.0.7253 + Linkage Engine:16.0.7253 + Patient Index:16.0.7253 + Provider Directory:15.0.7253 + Clinical Viewer:16.0.7253 + Active Analytics:16.0.7253]

Cache for Windows (x86-64) 2017.2.1 (Build 801U) Wed Dec 6 2017 09:07:51 EST [HealthShare Modules:Core:16.0.7241 + Linkage Engine:16.0.7241 + Patient Index:16.0.7241 + Provider Directory:15.0.7241 + Clinical Viewer:16.0.7241 + Active Analytics:16.0.7241]

Thanks very much Robert - that's got me much further!

Script-1 (JWTToObject) creates an object from a valid JWT.
Script-2 (ObjectToJWT) contains Robert's fixes to localpub and localpriv.

Script-1:
ERROR #8897: No public key found for alg: RS256 (kid:)

Script-2:
ERROR #8896: No private key found for alg: RS256

So it seems to me as though its the node code that produces the private and public portions of the RSA key that's used in the localpub and localprov variables that's at fault?

Script-1.

s localpriv="{""keys"":[{""kty"":""RSA"",""use"":""sig"",""n"":""ALaMFdNTmzUu1wnMGNmsIkBMJUS4EdMAe2HXpQ-k4aDk94znJuCi9OJnJQU4lm4nqgEWdzMVVQMlqZ3ihlXx5vpFzmb4m4EkAcmK0ULVCLL9QRqvuwbOjeXW8pJlcH-EAQKnkMzF6GbtmmDubK46bx2GaQh8rLYAfLvoIwXfyrXIday2VdRNz_3yGzLoxr5QxcFml46479mY3xXwmTSMvVNHEN4F1xPnsLQoNPH3guA104dm8S-f2z_vczHBdSrgiJibesdOP3ugYlxJvDDT3WSf3WW7cjAn8M3vZmCNTPWe6JEewsc6cDBiFWn9UUomulFUV_uucTsV_NXMd8nQ_Hs"",""e"":""AQAB"",""d"":""WSQxKEAkg6T651LeM7VmCGXmsRb9xT7wAUhv1yLZ91q4M_tQtdN9p-1cW59VfjcqQlu5G53oJKBIosvSc7er5j0eXJQ8Q6TUppl-NJeZJuaa2zBDMUC-dCUx0SF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frafeRIAJsw693z_l9KhCNC-v8vJ_b4_iDREa3c6dCz5GEtANiv9phfzPUL2x7CHMHu-lENBvVNDtl0-Gt0HCD6RFf7NJeH7oYeKR2NpcCT93gCQhX32EMLr5eFJeBw"
 
K JOSE SET ST=##class(%OAuth2.JWT).JWTToObject(JWT,localpriv,localpub,.JOSE,.Body)
 
d $system.OBJ.DisplayError(ST)
 
ERROR #8897: No public key found for alg: RS256 (kid:).

Script-2.

KILL JOSE
S JOSE("sigalg")="RS256"

S A=+$H-47117 // (47117 = 01/01/1970)
// (60*60)*24 (total number of secs in a day)
S B=A*86400
S C=$P($HOROLOG,",",2)
S EPOCH=B+C
// add 4 minutes
S D=60*4
S EPOCH=EPOCH+D

set body=##class(%DynamicObject).%New()
do body.%Set("sub","JWTClientCredentials","string")
do body.%Set("jti","3a497a96-ca48-45d7-b34a-31f5f93c83f3","string")
do body.%Set("iss","JWTClientCredentials","string")
do body.%Set("aud","https://fhir.careevolution.com/Master.Adapter1.WebClient/identityserver/...","string")
do body.%Set("exp",EPOCH,"string")
do body.%Set("nbf",EPOCH,"string")

s localpriv="{""keys"":[{""kty"":""RSA"",""use"":""sig"",""n"":""ALaMFdNTmzUu1wnMGNmsIkBMJUS4EdMAe2HXpQ-k4aDk94znJuCi9OJnJQU4lm4nqgEWdzMVVQMlqZ3ihlXx5vpFzmb4m4EkAcmK0ULVCLL9QRqvuwbOjeXW8pJlcH-EAQKnkMzF6GbtmmDubK46bx2GaQh8rLYAfLvoIwXfyrXIday2VdRNz_3yGzLoxr5QxcFml46479mY3xXwmTSMvVNHEN4F1xPnsLQoNPH3guA104dm8S-f2z_vczHBdSrgiJibesdOP3ugYlxJvDDT3WSf3WW7cjAn8M3vZmCNTPWe6JEewsc6cDBiFWn9UUomulFUV_uucTsV_NXMd8nQ_Hs"",""e"":""AQAB"",""d"":""WSQxKEAkg6T651LeM7VmCGXmsRb9xT7wAUhv1yLZ91q4M_tQtdN9p-1cW59VfjcqQlu5G53oJKBIosvS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ncAbWlaw2Ny4VOKSk1AGVnqxzc3KPdvzng244cYq0YGu1UZyU8Oe8m4MrVyxLy0PD1gG3n6fx93o9QBDm2I2QGou1""}]}
"

s localpub="{""keys"":[
{""kty"":""RSA"",""use"":""sig"",""n"":""ALaMFdNTmzUu1wnMGNmsIkBMJUS4EdMAe2HXpQ-k4aDk94znJuCi9OJnJQU4lm4nqgEWdzMVVQMlqZ3ihlXx5vpFzmb4m4EkAcmK0ULVCLL9QRqvuwbOjeXW8pJlcH-EAQKnkMzF6GbtmmDubK46bx2GaQh8rLYAfLvoIwXfyrXIday2VdRNz_3yGzLoxr5QxcFml46479mY3xXwmTSMvVNHEN4F1xPnsLQoNPH3guA104dm8S-f2z_vczHBdSrgiJibesdOP3ugYlxJvDDT3WSf3WW7cjAn8M3vZmCNTPWe6JEewsc6cDBiFWn9UUomulFUV_uucTsV_NXMd8nQ_Hs"",""e"":""AQAB""}]}"


SET ST=##class(%OAuth2.JWT).ObjectToJWT(.JOSE,.body,localpriv,localpub,.JWT)

d $system.OBJ.DisplayError(ST)

ERROR #8896: No private key found for alg: RS256.