has anyone used cfoauth and been able to get a ref...
# adobe
r
has anyone used cfoauth and been able to get a refresh token? seems near impossible
b
Hi Ray, I realize this is not answering your question directly, I avoid using CF ColdFusion... Instead I use Lucee. So to get tokens... 1. Set a route that handles your redirect URL. Something like /mydomain.com/gimmemytoken.cfm. 2. Build a request URL that includes clientID, scope, redirect URL, and state. Then send it to their oauth api. 3. When the request comes back to your server, use url.code and url.state to build your token request. For that, I use something like this... http url=this.token_endpoint method="post" result="result" timeout="1000"{ httpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded"; httpparam type='header' name='Authorization' value="Basic " & auth; httpparam type='header' name='Host' value='oauth.platform'; httpparam type="body" value=postBody; }; Hey, if ColdFusion can do all that for you, I would be absolutely amazed.
👍 1
q
Ray -- from what I understand you shouldn't have to manage the refresh tokens yourself. It's supposed to auto-renew on it's own, as long as your session is still active.
At least, that's what I found when I was first working with it. We ended up having to roll our own because ACF would randomly end sessions (actually make the call to end the session) on it's own, and we couldn't figure out why.
r
Bill, thank you, I know how oauth works, I was mainly wondereing why cfoauth doesn't seem to support it.
Bill - that's not my understanding. When working w/ Google's oauth directly for ex, you can get an access token -and- refresh token when you exchange the code you get back at the end of the flow. access tokens live for an hour, but refresh ones let you get more later. I want that so I don't have to worry about the token expiring
b
Hi Ray, if I understand you correctly, once I get the first refresh_token, I request (and store) a new refresh_token "prior" to each API call. To your point, that will keep your refresh_token active forever if your app is being used regularly. For that, include "grant_type=refresh_token" along with your existing refresh_token in the body of your call. That will return an access_token you can use for the call, and a brand spanking new refresh_token you can store for later.
r
ok, but thats the issue - you cant get the refresh_token at all. if you do oauth manual, yes, you can specify you want it and when you exchange the code, you get an access token and rerefresh token.
according to the google docs, if you pass access_type=offline, you will be able to get it. i tried using urlparams attribute of cfoauth, but it doesnt work
if i do everything "manually", it works fine
b
when you say manually, does that mean using CURL?
r
no, cfhttp.
well, also when i generate the linkj myself in cfml
cfoauth handles making, and redirecting for you
b
okay gotcha
As mentioned, I don't use any version of ColdFusion that might have tag named cfoauth. I do this manually as well using cfhttp.
r
yeah, thats what ive done in the past.
b
Personally, and no offense to Adobe, but I prefer Lucee. Yes, there are tags missing perhaps, but most of the stuff can be written fairly easily.
I guess that is the main thing. If you use ColdFusion, it would be nice if a tag like that worked in your favor.
r
im typically not a fan of any CF tag that does stuff on the client, which this kinda does. but i was a bit impressed by it.