Permalink
Browse files

Merge branch 'release/0.4.9'

Conflicts:
	application.properties
  • Loading branch information...
2 parents a915944 + eb7a00e commit 095ab1788d9fc690492dde4894221762926cff3b @benorama benorama committed Mar 19, 2013
View
@@ -0,0 +1,4 @@
+language: groovy
+jdk:
+ - oraclejdk7
+script: ./grailsw refresh-dependencies && ./grailsw clean && ./grailsw "test-app unit:"
@@ -2,7 +2,7 @@ import grails.plugin.facebooksdk.*
class FacebookSdkGrailsPlugin {
- def version = "0.4.8"
+ def version = "0.4.9"
def grailsVersion = "2.0 > *"
def author = "Benoit Hediard"
View
@@ -1,6 +1,8 @@
Facebook SDK Grails Plugin
==========================
+[![Build Status](https://travis-ci.org/benorama/grails-facebook-sdk.png)](https://travis-ci.org/benorama/grails-facebook-sdk)
+
# Introduction
The [Facebook Platform](http://developers.facebook.com/) is a set of APIs that make your application more social. Read more about [integrating Facebook with your web site](http://developers.facebook.com/docs/guides/web) on the Facebook developer site.
@@ -34,7 +36,7 @@ grails.project.dependency.resolution = {
}
plugins {
//here go your plugin dependencies
- runtime ':facebook-sdk:0.4.8'
+ runtime ':facebook-sdk:0.4.9'
}
}
```
@@ -75,6 +77,7 @@ Project documentation is located here :
WARNING: Since V0.4.0, _FacebookApp_, _FacebookSdkFilters_ and _FacebookAppService_ from V0.3.* are DEPRECATED and have been replaced by _FacebookContext_.
Please check [FacebookContext](http://benorama.github.com/grails-facebook-sdk/guide/facebookContext.html) doc for more info.
+* 2013-03-19 **V0.4.9** : bug fix token exchange from code with concurrent requests (thanks to [elegorod](https://github.com/elegorod))
* 2013-01-03 **V0.4.8** : bug fix token expiration time handling (in Facebook Page tabs)
* 2012-12-20 **V0.4.7** : bug fix resources definition
* 2012-12-07 **V0.4.6** : bug fix in invite/publish/send tags (encode text as HTML in attributes)
View
@@ -1,3 +1,4 @@
-#Thu Dec 20 15:07:15 CET 2012
-app.grails.version=2.1.3
+#Grails Metadata file
+#Thu Mar 14 17:24:11 CET 2013
+app.grails.version=2.2.1
app.name=grails-facebook-sdk
View
12 grailsw
@@ -118,7 +118,7 @@ fi
if [ -z "$STARTER_CONF" ]; then
STARTER_CONF="$GRAILS_HOME/conf/groovy-starter.conf"
fi
-STARTER_CLASSPATH="wrapper/grails-wrapper-runtime-2.1.3.jar:wrapper:."
+STARTER_CLASSPATH="wrapper/grails-wrapper-runtime-2.2.1.jar:wrapper:."
# Allow access to Cocoa classes on OS X
if $darwin; then
@@ -180,15 +180,15 @@ if $cygwin ; then
fi
if [ -z "$GRAILS_AGENT_CACHE_DIR" ]; then
- GRAILS_AGENT_CACHE_DIR=~/.grails/2.1.3/
+ GRAILS_AGENT_CACHE_DIR=~/.grails/2.2.1/
fi
-SPRINGLOADED_PARAMS="profile=grails;cacheDir=$GRAILS_AGENT_CACHE_DIR"
+SPRINGLOADED_PARAMS=profile=grails;cacheDir=$GRAILS_AGENT_CACHE_DIR
if [ ! -d "$GRAILS_AGENT_CACHE_DIR" ]; then
- mkdir -p $GRAILS_AGENT_CACHE_DIR
+ mkdir -p "$GRAILS_AGENT_CACHE_DIR"
fi
# Process JVM args
-AGENT_STRING="-javaagent:wrapper/springloaded-core-1.1.1.jar -noverify -Dspringloaded=$SPRINGLOADED_PARAMS"
+AGENT_STRING="-javaagent:wrapper/springloaded-core-1.1.1.jar -noverify -Dspringloaded=\"$SPRINGLOADED_PARAMS\""
CMD_LINE_ARGS=""
DISABLE_RELOADING=false
@@ -302,7 +302,7 @@ startGrails() {
then
GRAILS_OPTS="$GRAILS_OPTS"
else
- GRAILS_OPTS="-server -Xmx768M -Xms768M -XX:PermSize=256m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8"
+ GRAILS_OPTS="-server -Xmx768M -Xms64M -XX:PermSize=32m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8"
fi
JAVA_OPTS="$GRAILS_OPTS $JAVA_OPTS $AGENT"
# Start the Profiler or the JVM
View
@@ -60,13 +60,13 @@ if "%GRAILS_HOME:~-1%"=="\" SET GRAILS_HOME=%GRAILS_HOME:~0,-1%
:init
for %%x in ("%HOMEPATH%") do set SHORTHOME=%%~fsx
-if "x%GRAILS_AGENT_CACHE_DIR%" == "x" set GRAILS_AGENT_CACHE_DIR=%SHORTHOME%/.grails/2.1.3/
+if "x%GRAILS_AGENT_CACHE_DIR%" == "x" set GRAILS_AGENT_CACHE_DIR=%SHORTHOME%/.grails/2.2.1/
set SPRINGLOADED_PARAMS="profile=grails;cacheDir=%GRAILS_AGENT_CACHE_DIR%"
if not exist "%GRAILS_AGENT_CACHE_DIR%" mkdir "%GRAILS_AGENT_CACHE_DIR%"
-set AGENT_STRING=-javaagent:wrapper/springloaded-core-1.1.1.jar -noverify -Dspringloaded=%SPRINGLOADED_PARAMS%
+set AGENT_STRING=-javaagent:wrapper/springloaded-core-1.1.1.jar -noverify -Dspringloaded=\"%SPRINGLOADED_PARAMS%\"
set DISABLE_RELOADING=
-if "%GRAILS_OPTS%" == "" set GRAILS_OPTS=-server -Xmx768M -Xms768M -XX:PermSize=256m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8
+if "%GRAILS_OPTS%" == "" set GRAILS_OPTS=-server -Xmx768M -Xms64M -XX:PermSize=32m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8
@rem Get command-line arguments, handling Windows variants
if "%@eval[2+2]" == "4" goto 4NT_args
@@ -130,7 +130,7 @@ set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
-set STARTER_CLASSPATH=wrapper/grails-wrapper-runtime-2.1.3.jar;wrapper;.
+set STARTER_CLASSPATH=wrapper/grails-wrapper-runtime-2.2.1.jar;wrapper;.
if exist "%USERPROFILE%/.groovy/init.bat" call "%USERPROFILE%/.groovy/init.bat"
@@ -159,7 +159,7 @@ set JAVA_OPTS=%GRAILS_OPTS% %JAVA_OPTS% %AGENT%
set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name="%PROGNAME%"
set JAVA_OPTS=%JAVA_OPTS% -Dgrails.home="%GRAILS_HOME%"
-set JAVA_OPTS=%JAVA_OPTS% -Dgrails.version=2.1.3
+set JAVA_OPTS=%JAVA_OPTS% -Dgrails.version=2.2.1
set JAVA_OPTS=%JAVA_OPTS% -Dbase.dir=.
set JAVA_OPTS=%JAVA_OPTS% -Dtools.jar="%TOOLS_JAR%"
set JAVA_OPTS=%JAVA_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%"
@@ -174,4 +174,3 @@ if "%OS%"=="Windows_NT" endlocal
@rem Optional pause the batch file
if "%GROOVY_BATCH_PAUSE%" == "on" pause
-
@@ -14,7 +14,7 @@ grails.project.dependency.resolution = {
}
plugins {
//here go your plugin dependencies
- runtime ':facebook-sdk:0.4.8'
+ runtime ':facebook-sdk:0.4.9'
}
}
{code}
@@ -21,6 +21,7 @@ WARNING: Since V0.4.0, @FacebookApp@, @FacebookSdkFilters@ and @FacebookAppServi
Please check [@FacebookContext@|guide:facebookContext] doc for more info.
{warning}
+* 2013-03-19 *V0.4.9* : bug fix token exchange from code with concurrent requests (thanks to "elegorod":https://github.com/elegorod )
* 2013-01-03 *V0.4.8* : bug fix token expiration time handling (in Facebook Page tabs)
* 2012-12-20 *V0.4.7* : bug fix resources definition
* 2012-12-07 *V0.4.6* : bug fix in invite/publish/send tags (encode text as HTML in attributes)
@@ -12,8 +12,8 @@ class FacebookContext implements InitializingBean {
private final static List DROP_QUERY_PARAMS = ['code','state','signed_request']
- GrailsApplication grailsApplication // Injected by Spring
- LinkGenerator grailsLinkGenerator // Injected by Spring
+ def grailsApplication // Injected by Spring
+ def grailsLinkGenerator // Injected by Spring
FacebookContextApp app
FacebookContextPage page // Only if app is running in a page tab and signed request exists in params (initial request)
@@ -99,15 +99,8 @@ class FacebookContextUser {
context.session.setData('token', token)
} else if (context.signedRequest.code) {
// Facebook Javascript SDK puts an authorization code in signed request
- if (context.signedRequest.code == context.session.getData('code')) {
- if (!isTokenExpired()) {
- _token = context.session.getData('token')
- log.debug "Got token from code (token=$_token)"
- if (isTokenExpiredSoon()) {
- exchangeToken()
- }
- }
- } else {
+ boolean loadedFromCode = loadSavedTokenFromCode(context.signedRequest.code)
+ if (!loadedFromCode) {
_token = getTokenFromCode(context.signedRequest.code)
log.debug "Got token from signed request code (token=$_token)"
}
@@ -227,9 +220,36 @@ class FacebookContextUser {
}
} catch (FacebookOAuthException exception) {
log.warn "Could not get token from code: $exception.errorMessage"
+ if (exception.errorCode == 100) {
+ // Authorization code has already been used.
+ // Token might have been received by another concurrent process, trying to extract it from session retries were made for distributed session replication
+ for(i in 0..<10) {
+ sleep(100 + 300 * i)
+ log.debug "Retry $i to load from code"
+ boolean loadedFromCode = loadSavedTokenFromCode(code)
+ if (loadedFromCode) {
+ return _token
+ }
+ }
+ }
invalidate()
}
return accessToken
}
+ private boolean loadSavedTokenFromCode(String code) {
+ boolean result = false
+ if (code == context.session.getData('code')) {
+ result = true
+ if (!isTokenExpired()) {
+ _token = context.session.getData('token')
+ log.debug "Got token from code (token=$_token)"
+ if (isTokenExpiredSoon()) {
+ exchangeToken()
+ }
+ }
+ }
+ return result
+ }
+
}

0 comments on commit 095ab17

Please sign in to comment.