agorapulse / grails-facebook-sdk

Facebook SDK Grails Plugin
http://agorapulse.github.com/grails-facebook-sdk/guide
30 stars 13 forks source link

Version 10 of Plugin exchangeToken() does not work #56

Closed confile closed 11 years ago

confile commented 11 years ago

I have tried to get a lon term (2 month token) with exchangeToken() as follows:

log.info "expireTime: "+new Date(facebookContext.user.tokenExpirationTime)

facebookContext.user.exchangeToken()

println "New token: $facebookContext.user.token"
log.info "expireTime new Token: "+new Date(facebookContext.user.tokenExpirationTime)

it turns out that both tokens are the same. This is alway the case. Both tokens are only valid for 2 hours. Is there something wrong with the exchange method?

benorama commented 11 years ago

The token should be exchanged, but expiration time is currently not updated in the request scope, so you do not see the new value (this will be fixed in 4.0.11 version released tomorrow). Try to re-execute the request, you should see the new expiration time.

confile commented 11 years ago

@benorama Please check it again. I my case the token remains the same. Or is there something wrong in the code above?

confile commented 11 years ago

@benorama what do you mean by re-exchange the request?

benorama commented 11 years ago

Sorry, I could not reproduce the issue.

In https://github.com/agorapulse/grails-facebook-sdk-demo , I've added the following code in @WebsiteController@ at L.24 and it worked fine.

println "Old token: $token"
println "expireTime: "+new Date(facebookContext.user.tokenExpirationTime)

facebookContext.user.exchangeToken()

println "New token: $facebookContext.user.token"
println "expireTime new Token: "+new Date(facebookContext.user.tokenExpirationTime)
confile commented 11 years ago

It is working now. I get the long term token as first token. Don't know why, but it works.