play-components / play-fbconnect

Easily integrate Facebook authentication into any Play framework application.
26 stars 13 forks source link

Exception in FBConnect callback. #1

Closed daveof closed 13 years ago

daveof commented 14 years ago

I am having a problem connecting to Facebook because my client_secret parameter contains a pipe character (|). The line String response = WS.url(authUrl).get().getString(); generates an exception

Execution exception (In {module:fbconnect-0.1}/app/controllers/FBConnect.java around line 27) RuntimeException occured : java.lang.IllegalArgumentException

play.exceptions.JavaExecutionException: java.lang.IllegalArgumentException at play.mvc.ActionInvoker.invoke(ActionInvoker.java:285) at Invocation.HTTP Request(Play!) Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException at play.libs.ws.WSAsync$WSAsyncRequest.get(WSAsync.java:109) at controllers.FBConnect.callback(FBConnect.java:36) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:408) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:403) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:176) ... 1 more Caused by: java.lang.IllegalArgumentException at java.net.URI.create(URI.java:842) at com.ning.http.client.RequestBuilderBase.buildUrl(RequestBuilderBase.java:265) at com.ning.http.client.RequestBuilderBase.setUrl(RequestBuilderBase.java:260) at com.ning.http.client.AsyncHttpClient$BoundRequestBuilder.setUrl(AsyncHttpClient.java:327) at com.ning.http.client.AsyncHttpClient.requestBuilder(AsyncHttpClient.java:488) at com.ning.http.client.AsyncHttpClient.prepareGet(AsyncHttpClient.java:383) at play.libs.ws.WSAsync$WSAsyncRequest.get(WSAsync.java:106) ... 5 more Caused by: java.net.URISyntaxException: Illegal character in query at index 236: https://graph.facebook.com/oauth/access_token?client_id=0000000000000000&redirect_uri=http://127.0.0.1:9000/fbconnect/oauth/callback&client_secret=6c4ab332d2ffa800659c934489a6cb04&code=2.dfsfd6dfdsfqJ4K7eRAH6SQtBw__.3600.1290690000-636994782|k1Mm5krKf8as87-0a3uaq4cZxR0 at java.net.URI$Parser.fail(URI.java:2809) at java.net.URI$Parser.checkChars(URI.java:2982) at java.net.URI$Parser.parseHierarchical(URI.java:3072) at java.net.URI$Parser.parse(URI.java:3014) at java.net.URI.(URI.java:578) at java.net.URI.create(URI.java:840) ... 11 more

mmurray commented 14 years ago

Ah yes, those query string parameters should definitely be encoded. I just pushed a patch to github and to the play module repository.

Thanks for the bug report!

sanity commented 13 years ago

I just got this in fbconnect-0.3:

Caused by: java.net.URISyntaxException: Illegal character in query at index 240: https://graph.facebook.com/oauth/access_token?client_id=184868531547213&redirect_uri=http://local.rank.my:9000/fbconnect/oauth/callback&client_secret=738fd21f012d3a7cb40e379663590c5f&code=2.p2BLC_MSHVvo9N5EeFq_bA__.3600.1296691200-534496019|Hf_Dar_LB0zLVgwHrMkLFC3bA0g
at java.net.URI$Parser.fail(URI.java:2809)
at java.net.URI$Parser.checkChars(URI.java:2982)
at java.net.URI$Parser.parseHierarchical(URI.java:3072)
at java.net.URI$Parser.parse(URI.java:3014)
at java.net.URI.<init>(URI.java:578)
at java.net.URI.create(URI.java:840)

Shouldn't it be fixed in that version?

johannesfritsch commented 13 years ago

Same here, got this error with latest version from play module repo.

johannesfritsch commented 13 years ago

I did a quick hack to solve this issue and sent an pull request to murz.

mmurray commented 13 years ago

Hey guys, I just pushed a version that builds the URLs in a different way. Everything should be properly encoded - can one of you pull down the latest and confirm?

https://github.com/murz/play-fbconnect/commit/095e24e1b140603f526a2b1842e206e1a52b61cc

mmurray commented 13 years ago

It looks like this is actually a bug with Play's WS class. It should be fixed soon because all they need to do is upgrade a dependency.

You can follow the ticket here: http://play.lighthouseapp.com/projects/57987/tickets/582-async-http-client-140-and-javaneturisyntaxexception#ticket-582-1

And there is some discussion about it on the google group: http://groups.google.com/group/play-framework/browse_thread/thread/974616c47fcca672