So related to my last msg. I'm sending a JWT to an...
# adobe
r
So related to my last msg. I'm sending a JWT to an endpoint to get an access token. Code works fine in Lucee, not in ACF, and the error mentions that the JWT is not properly encoded. So I'm assuming a slight diff in cfhttp in the two. Has anyone seen this before?
b
Adobe and Lucee do have different settings regarding encoding of params
r
figured as much. i may need to rediect my POST to an 'echo' to see if something is obvious
b
The one that bites me is how Lucee auto-encodes the URI, which you can turn off with this setting https://docs.lucee.org/reference/tags/http.html#attribute-encodeurl
However, I'm not clear how/where you're passing the JWT in your case
r
Copy code
body = "client_id=#variables.client_ID#&client_secret=#variables.client_secret#&jwt_token=#variables.jwt_token#";

writedump(body);

cfhttp(method="post", url="<https://ims-na1.adobelogin.com/ims/exchange/jwt>", redirect=true) {
	cfhttpparam(type='header', name='Content-Type', value='application/x-www-form-urlencoded');
	cfhttpparam(type='body', value=body);
}
writeoutput("<hr>");
writedump(cfhttp.filecontent);
ugly quick code 🙂
b
Not sure why you're making your own body, that seems terrible 🙂
Send them as invidiual fields
r
this was copied from Node code where the body is a set of key/value pairs
b
Otherwise, you'd need to URL encode those values as you built the string
Here's some code I have for a client app doing oauth stuff
Copy code
http method="POST" url="<https://login.microsoftonline.com/.../oauth2/v2.0/token>" result="local.cfhttp" {
            httpparam type="formfield" name="client_id" value="...";
            httpparam type="formfield" name="scope" value="User.Read";
            httpparam type="formfield" name="code" value=rc.code;
            httpparam type="formfield" name="redirect_uri" value="#session.redirectURL#";
            httpparam type="formfield" name="grant_type" value="authorization_code";
            httpparam type="formfield" name="client_secret" value="...";
        }
That's Lucee-specific syntax BTW
but just send them as form fields
r
yeah i tried something similar -
b
CF will encode them in the request body
r
Copy code
cfhttp(method="post", url="<https://ims-na1.adobelogin.com/ims/exchange/jwt>", redirect=true) {
	cfhttpparam(type='header', name='Content-Type', value='application/x-www-form-urlencoded');
	cfhttpparam(type='formfield', name='client_id', value=client_id);
	cfhttpparam(type='formfield', name='client_secret', value=client_secret);
	cfhttpparam(type='formfield', name='jwt_token', value=jwt_token);
}
same result
b
r
thats for type=url though, right?
or cgi
b
Not sure what the docs mean by "cgi", that has nothing to do with form posts, lol
r
you can send CGI values in a network request i believe
im resorting to the "post to echo.cfm" and running ACF+Lucee
fascinating - yep, i see a difference
ACF is urlencoding
and i can turn that off... and yet my post still doesnt work. sigh
ahah!
its the NAME. ACF is changing jwt_token to jwt%5token