play-components / play-fbconnect Goto Github PK
View Code? Open in Web Editor NEWEasily integrate Facebook authentication into any Play framework application.
Easily integrate Facebook authentication into any Play framework application.
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.IllegalArgumentExceptionplay.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
If facebook applications with offline_access
permissions get allowed, they don't return expires
parameter and this plugin throws the following error
Unexpected error : Module fbconnect could not find access token and expires in facebook callback
other problem is callback method is called back with the following URL FBConnect.java
and it does not have expires
. Maybe Facebook changed something?
http://localhost:9000/fbconnect/oauth/callback?code=AQDZXiYDxxxxxxxxxxxxxxxxxxxxxxxxxMWe1VB7c#_=_
Please confirm.
fbconnect-0.6 installation doesn't appear to work with Play! 1.2.4. We've worked out how to get it working (http://stackoverflow.com/questions/8860560/playframework-integration-with-fbconnect/8860829#8860829), but thought you might be able to correct the standard dependency installation.
All the best,
Craig
Version: fbconnect-head
play auto-test results with:
Caused by: java.lang.NullPointerException
at tags.fbconnect.FBConnectTags._button(FBConnectTags.java:26)
at tags.fbconnect.FBConnectTags$_button.call(Unknown Source)
at /app/views/Application/displayComix.html.(line:92)
Running test in browser goes smoothly though.
This happens on page which contains fbconnect button.
Hi murz,
I had some users getting a 400 error when trying to login using fb. Is it not always happening, can't really figure out what's causing that response but reading around seems that the same redirect uri must be used when getting the oauth dialog and when calling the graph api? Could that be the problem?
This is what the stack trace looks like, any help would be appreciated.
RuntimeException occured : java.io.IOException: Server returned HTTP response code: 400 for URL: https://graph.facebook.com/oauth/access_token?client_id=XXXX&redirect_uri=XXX&client_secret=XXX&code=XXX
I'm trying to install the module on my device. However, it fails for some reason. I'm using play-1.2.3 and using play install fbconnect-0.6
.
$ play install fbconnect-0.6
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2.3, http://www.playframework.org
~
~ Will install fbconnect-0.6
~ This module is compatible with: 1.2
~ Do you want to install this version (y/n)? y
~ Installing module fbconnect-0.6...
~
~ Fetching http://www.playframework.org/modules/fbconnect-0.6.zip
~ [--------------------------100%-------------------------] 33229.5 KiB/s
~ Unzipping...
Traceback (most recent call last):
File "/Users/alp/play-1.2.3/play", line 153, in <module>
status = cmdloader.commands[play_command].execute(command=play_command, app=play_app, args=remaining_args, env=play_env, cmdloader=cmdloader)
File "/Users/alp/play-1.2.3/framework/pym/play/commands/modulesrepo.py", line 58, in execute
install(app, args, env)
File "/Users/alp/play-1.2.3/framework/pym/play/commands/modulesrepo.py", line 391, in install
Unzip().extract(archive, os.path.join(env["basedir"], 'modules/%s-%s' % (module, v['version'])))
File "/Users/alp/play-1.2.3/framework/pym/play/commands/modulesrepo.py", line 152, in extract
outfile = open(os.path.join(dir, name), 'wb')
IOError: [Errno 13] Permission denied: '/app/controllers/FBConnect.java'
Then I try it with sudo
.
$ sudo play install fbconnect-0.6
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2.3, http://www.playframework.org
~
~ Will install fbconnect-0.6
~ This module is compatible with: 1.2
~ Do you want to install this version (y/n)? y
~ Installing module fbconnect-0.6...
~
~ Fetching http://www.playframework.org/modules/fbconnect-0.6.zip
~ [--------------------------100%-------------------------] 25840.4 KiB/s
~ Unzipping...
~
~ Module fbconnect-0.6 is installed!
~ You can now use it by adding it to the dependencies.yml file:
~
~ require:
~ play -> fbconnect 0.6
However after navigating to the folder using
$ cd fbconnect-0.6
only the following files are installed:
README.md build.xml manifest
what can be the problem?
@673lhjoh8
Cannot start in PROD mode with errors
Compilation error (In {module:fbconnect-0.5}/app/controllers/FBConnect.java around line 39)
The file {module:fbconnect-0.5}/app/controllers/FBConnect.java could not be compiled. Error raised is : The method newRequest(String, String) in the type WSUrlFetch is not applicable for the arguments (String)
play.exceptions.CompilationException: The method newRequest(String, String) in the type WSUrlFetch is not applicable for the arguments (String)
at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:246)
at org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.java:672)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:516)
at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:278)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:412)
at play.Play.preCompile(Play.java:563)
at play.Play.init(Play.java:291)
at play.server.Server.main(Server.java:158)
~
~ Precompilation has failed, stop deploying.
~
With the version you last pushed to master, is impossible to get the access_token parameter returned by facebook.
Here the patch i wrote in the file FBConnect.java
import com.google.gson.JsonPrimitive;
JsonObject jsonData = WS.url(uri).get().getJson().getAsJsonObject();
jsonData.add("accessToken", new JsonPrimitive(accessToken));
and thats it!!!! now i have access to allData from the user authenticated.!!
I hope you include this on your project. Its very simple and we get so much!!
Hi Murz,
Playin around with your contribution, I'm getting the following error
when deploying my app to gae and clicking on the link. Seems like absolute url is not found...
Am I missing something ?
thx alot
When my application tries to authenticate to Facebook, code throws an InvocationTargetException
at FBConnect.java
and code steps into
[...]
}catch(InvocationTargetException e){
throw new UnexpectedException("Module fbconnect encountered an error while calling your model's findForFacebookOAuth: "+e.getMessage());
}
and throws the exception. (Interestingly, e.getMessage()
is null at this point. Maybe that InvTargetExceptn does not have a message?)
Then I found out that the method name findForFacebookOAuth
(mentioned in exception) does not exist in the code at all (I grepped) and probably it is facebookOAuthCallback
that you mentioned in line
Method method = model.getMethod("facebookOAuthCallback", new Class[] { JsonObject.class });
Interestingly I have a method in the User model class that I configured that matches what the plugin requires.
public static void facebookOAuthCallback(JsonObject data)
However I still get that exception. A bug?
Hi!
I sometimes have this exception in my code, it really depends (that's gonna be hard to explain how to reproduce it :s).
Here the stack:
play.exceptions.JavaExecutionException: This is not a JSON Object.
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:231)
at play.server.PlayHandler$NettyInvocation.execute(PlayHandler.java:257)
at play.Invoker$Invocation.run(Invoker.java:278)
at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:235)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: This is not a JSON Object.
at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:83)
at controllers.FBConnect.callback(FBConnect.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:551)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
... 11 more
I guess adding a try/catch where you try to parse the JSON response from Facebook should fix this problem. maybe.
(sorry I'm not for more help on it!)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.