client_id
client_secret
redirect_uri
response_type
state
I have valid values for all the parameters.
If I run the URL with parameters and their respective values by hand, it works as expected, however, when I put the above URL with parameters and values into a variable, and with username and password for the CFHTTP call, it prompts for username and password.
I wonder if any of you have experienced the same, and how did you overcome it?
Thanks in advance.
P.S. It would be nice to be able to add new category such as LinkedIn or API etc…
I haven’t used the LinkedIn API before, but I think you may be misunderstanding the authorization/authentication process. According to the docs, the URL you’re trying to call is for your users to visit so that they can grant your app the permissions it needs. You should send them there via a cflocation with the appropriate url parameters, rather than cfhttp.
Once they’ve granted permission (Step 2 in the docs), you’ll need cfhttp to make a POST request to the API and get your access token (Step 3). Once you have that, you’ll be able to make authenticated calls (Step 4) also using cfhttp.
A username/password doesn’t seem to be needed at any stage.
Very helpful. At step 3, once I return results such as {"access_token":"AQUzDl3Wx752b6CJGuGgkiskdMnDD30Ra2oMdT7sC8mCvDd3DXIQulj7AEgFTVFhVlkV2MTtn3An6jntg_ikGKTVhjgeJLWUeh4WmQeYuqMqzlh6er2R7DumVEstXTY8-7Ix0bo4-u8siq5TwrOa-pSv2Z9bIENMutjzAkjdgrnmocj0ov0FMg","expires_in":5283999}
How can we extract the access_token value and expires_in value out of it?
The output looks like an array, thus, I attempted #cfhttp.fileContent["access_token"]#, but it looks like #cfhttp.filecontent# is complex string. What’s a good way to get these two values and we move to next step?
Good thought, Julian, I’ve added this cfhttpparam line right under the “Content-Type” one,
and yet, still same error of "405 Method Not Allowed ". Thanks.
Based on the above, so, I’ve revised the code accordingly, specifically as follows (var stuff has been defined and we have the #access_token# as well of course):
The error suggests a problem with the request method, but it’s definitely POST in the docs, and the content type headers seem fine. You are missing the “submitted-url” and “submitted-image-url” values from your share data, but unlikely that would cause the error. Does the reponse include a more detailed “message” field of any kind?
After some offline discussion, it seems the issue is with the way Lucee encodes the url in cfhttp by default which was causing the tilde character (~) in the LinkedIn endpoint not to be recognized.
The fix is just to add encodeUrl=false to the cfhttp tag like so:
Hi Julian, I wonder if you have some contact at Linked API because I’d like to find out if it’s API is able to let one retrieve update of anyone on the LinkedIn (with his/her user id). I’ve googled for answers and stackoverflow as well, however, to no avail. Thus, only their own API engineer would know.
Many thanks.
Don