Comments (66)
Same here (fbsr_ cookie is set), also fbml login button doesnt detect 'logged in' status correctly with autologoutlink: true.
from fosfacebookbundle.
@stoefln, @pentarim - what version of Facebok php-sdk you have? You must have function "getSignedRequestCookieName" in Facebook class.
from fosfacebookbundle.
oh, that function is missing! i have:
commit 0c0911b76a7392b0a1435e7f6650b74225c2d8ef
Author: Paul Tarjan [email protected]
Date: Wed Aug 10 02:44:11 2011 -0700
from fosfacebookbundle.
@ahilles107 I have that function, and am able to log in with chrome, but get the "The Facebook user could not be retrieved from the session." for firefox & konqueror, some js issue maybe, can anybody confirm this?
from fosfacebookbundle.
@pentarim maybe you mast set P3P: CP="HONK" header in your response.
from fosfacebookbundle.
@ahilles107 tried P3P: CP="HONK", but it doesnt seem to help (good idea tho :)
from fosfacebookbundle.
I get the same error. I have the function "getSignedRequestCookieName" in base_facebook.php
from fosfacebookbundle.
Played with it a bit and when I get "The Facebook user could not be retrieved from the session." and manually enter /login_check in address bar I get authenticated with FF4. Checked with tamper data, and upon granting permissions I also get redirected to /login_check (which sends me to /login with mentioned error) , but maybe the cookie isnt set yet at that moment (just guessing here), hope this helps
from fosfacebookbundle.
I don't get how the whole process of logging in server side, via a client side set cookie should work.
Can anyone guide me through this, or give me hints how to debug this?
However: fbs_ cookie gets set, so client side login works, but server side does not. symfony stays logged out.
from fosfacebookbundle.
and could someone point out which revision of the facebook sdk is needed?
from fosfacebookbundle.
@stoefln: we need 3.1.1 facebook-sdk. New sdk don't support fbs_ cookie, only new fbsr_. If you wan't i can help you, try this https://github.com/ahilles107/symfony-facebook
from fosfacebookbundle.
thanks. but I still get: "The Facebook user could not be retrieved from the session."
from fosfacebookbundle.
@stoefln you tried https://github.com/ahilles107/symfony-facebook ??
from fosfacebookbundle.
not so far, since i already have a quite big app. will try to integrate it ASAP though...
Thanks so far!
from fosfacebookbundle.
I'm getting this same message when I use Safari, and sometimes in FF 6 and Chrome (very weird because it happens randomly). I even created a fresh symfony instance using Symfony 2.0.1 and the latest versions of FOSFacebook and FOSUser:
https://github.com/gigo6000/symfony-facebook
from fosfacebookbundle.
Has anything changed/planned with this issue or we should not expect a solution to it soon? Its a blocker for me
from fosfacebookbundle.
I do not use the integration on the website. It will be difficult to help. Are you sure this is our fault or Facebook.
from fosfacebookbundle.
I am sure that integration is not working, but dont know nearly enough to determine the fault. I get authenticated after "The Facebook user could not be retrieved from the session." if I manually enter /login_check into address bar, so guess the auth part is fine just the cookie is not readable/not set at redirect to /login_check 1st time (guessing here). If its impossible to do, could you point me to some resources to do it purely server side (withouth js sdk). Thanks in advance!
from fosfacebookbundle.
here is what I just found out. Would be great if it could bring us one step further to a solution:
I tried to do the facebook connect just server side, without using the symfony auth handler and without any client side auth flow. What seemed strange to me:
- if i use $this->container->get('facebook') it does not work (infinite redirects, seems like some session thingy does not get set)
- if i use
new \Facebook(...)
the authentication flow works flawlessly.
could there be something wrong with the service?
here is the code:
protected function checkAndExtendFacebookPermissions($perms,$afterLoginUrl){ //$returnUrl = 'http://'.$this->getRequest()->getHost().$this->generateUrl('_validate_facebook'); $isGranted = false; $userId = $this->getFacebook()->getUser(); if($userId){ foreach($perms as $perm){ $isGranted = $this->getFacebook()->api(array( "method" => "users.hasAppPermission", "ext_perm" => $perm, "uid" => $userId, )); if(!$isGranted){ break; } } } if ($isGranted !== "1"){ $loginUrl = $this->getFacebook()->getLoginUrl(array( 'req_perms' => implode(',',$perms), //'next' => $returnUrl.'?_target_path='.'http://'.$this->getRequest()->getHost().$afterLoginUrl, )); return new RedirectResponse($loginUrl); }else{ $this->getUser()->setFacebookID($userId); $this->em()->persist($this->getUser()); $this->em()->flush(); return $this->redirect($afterLoginUrl); } }
from fosfacebookbundle.
I have had this problem and found solution for it. When facebook pop-up closes, the cookie fbsr_xxxx gets created and at the same time we get redirected to check path for validation. The redirection to check path happens slightly before the cookie gets created so, the cookie is not sent to the check path and $_COOKIE array does not have this cookie. I introduced 500 ms delay before redirecting to check path like this:
<script>
function go_login(){
window.location = "{{ path('fb_login_check') }}";
}
FB.Event.subscribe('auth.login', function(response) {
setTimeout("go_login()",500);
});
</script>
Now everything is working great.
This also gives explanation to the problem of @pentarim
from fosfacebookbundle.
wow- great to hear!
unfortunately i can't tests this now. switched to my own implementation of facebook connect...
from fosfacebookbundle.
tested it, it works with this workaround, thanks @adityapatadia
from fosfacebookbundle.
@stoefln would love to hear how your own implementation works!
from fosfacebookbundle.
@lightdiff: have you tried adityapatadia's approach?
my own implementation is based on not using the security interception layer, but doing everything by hand in a controller.
since i don't need a "facebook-login" right now, i just implemented a "facebook connect", meaning: you have to register with username, email, passw,... and in the next step you can connect your facebook account with your user account. however, it would be possible to do a "facebook-login" in the "facebookConnectAction()" too.
here is the gist: https://gist.github.com/1263863
let me know if you have further questions.
from fosfacebookbundle.
@stoefln I did start on a method similar to what you proposed, but got the "standard" script version working and have found it it quirky as quite a few have mentioned here. I'll revisit based on your description and the gist. Thanks for the help!
from fosfacebookbundle.
I just tested this and it worked, thanks. https://github.com/gigo6000/symfony-facebook
from fosfacebookbundle.
I am getting the same error, but only If i'm NOT logged into facebook. I'm sure this is a config issue. Here is the firewall config from security.yml...
firewalls:
public:
pattern: /.*
form_login:
login_path: /login
check_path: /login_check
default_target_path: /
fos_facebook:
login_path: /login
check_path: /login_check
default_target_path: /
logout: true
security: true
anonymous: true
I've spent all day trying various config changes and I cannot get it right. Any help is MUCH appreciated!
It works fine and I can log in with FOSUserBundle only if I am logged into facebook, otherwise I get "Facebook user cannot be retrieved from session"
from fosfacebookbundle.
@outlawscumbag : i got exactly the same problem !
from fosfacebookbundle.
@outlawscumbag, you should not use the same check_path for both FOSUserBundle and FOSFacebookrBundle
from fosfacebookbundle.
I tried everything, I did eventually separate the check_path after the previous comment but I still couldn't get it working, when it did work, then I couldnt log in from my form. I eventually gave up and used the facebook oauth sdk and just created a new user and new token, and authenticated the FB user with FOSUserBundle after successful FB auth.
from fosfacebookbundle.
Would love to see a working example of using FOSFacebookBundle and FOSUserBundle together with logging in via Facebook and logging in with username/password. Why isn't this standard functionality?
from fosfacebookbundle.
Yeah, I gave up on it. I'm sure it was a config issue, but deadlines suck haha =) So, I used Facebook oauth api and created a user token and a new user and authenticated them pragmatically as a user so they are authenticated by symfony2 app and facebook.
from fosfacebookbundle.
I couldn't make this work either.
I do not use FOSUserBundle and I have a regular login form who worked fine. Then I tried to integrate FOSFacebookBundle.
I am now able to authenticate via Facebook (Login / Logout buttons work fine) but my login for returns the error: "The Facebook user could not be retrieved from the session".
I am now unable to login via my regular login form. Any idea ?
Here is my configuration:
security.yml:
providers:
chain_provider:
providers: [user_db, fos_facebook]
user_db:
entity: { class: Acme\UserBundle\Entity\User, property: username }
fos_facebook:
id: fos_facebook.auth
firewalls:
main:
pattern: ^/*
form_login:
check_path: /login_check
login_path: /login
logout:
handlers: ["fos_facebook.logout_handler"]
security: true
anonymous: true
remember_me:
key: myKey
lifetime: 3600
path: /
domain: ~ # Defaults to the current domain from $_SERVER
fos_facebook:
app_url: "http://apps.facebook.com/Acme.com/"
server_url: "http://localhost/facebookApp/"
login_path: ^/login
check_path: ^/login_check
And my routing.yml:
_security_login:
pattern: /login
defaults: { _controller: AcmeUserBundle:Security:login }
_security_check:
pattern: /login_check
_security_logout:
pattern: /logout
I have read that I am not supposed to use the same routes for my two providers, but how can I configure them then? Can you give an example ?
Thank you as any help is really appreciated inhere !
By the way, I have run into this error while trying to debug what I was doing: Call to undefined method FOS\FacebookBundle\Security\Authentication\Provider\FacebookProvider::loadUserByUsername().
This occured when trying to login with a username which does not exist in the DB. I think someone is getting confused here as I should be dealing with the login form and not with Facebook.
I am sorry if this is trivial, but please state the obvious for me !
from fosfacebookbundle.
I spent days debugging login/facebook-login with FOSUserbundle and FOSFacebookbundle. Now we have troubles again loggin in on one dev machine in test environment. IMO the security interception layer does more harm than it does good. If you get stuck with it you really have a problem, unless you know the whole security concept of Symfony in-depth. That's why we switched to a workaround.
from fosfacebookbundle.
Well, it does make sense not to use the same route for both login actions but the underlying concepts are still quite confusing when you do not have a strong knowledge of what lies beneath these words.
I have read the doc again and again but I feel lost.
This bundle must have been set up successfully by some users... Could someone enlighten me, please ?
from fosfacebookbundle.
I spent also too many hours on this problem... and finally i did my own FormLogin provider and did somes changes in the FacebookUserProvider and everything was running in 15min.
from fosfacebookbundle.
@gregoryb: would you mind sharing how you managed to do that as I would be very interested in it. I am not looking for fancy stuff... Just a working Facebook integration :)
from fosfacebookbundle.
+1 for sharing a working implementation
from fosfacebookbundle.
please share it
from fosfacebookbundle.
Yes, it would be really great to see a complete example for FOSUserBundle forms and FB login at the same time.
from fosfacebookbundle.
Hi, there is already a manual as FosUserBundle and FosFacebookBundle work together? I just do not get it to work.
from fosfacebookbundle.
Anyone got this working on Symfony 2.0?
Im using SF2.0.7 and just can't get it working
I got an error You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.
security.yaml
security:
factories:
- "%kernel.root_dir%/../vendor/bundles/FOS/FacebookBundle/Resources/config/security_factories.xml"
providers:
fos_userbundle:
id: fos_user.user_manager
my_fos_facebook_provider:
id: my.facebook.user
encoders: "FOS\UserBundle\Model\UserInterface"
firewalls:
main:
pattern: .*
form_login:
provider: fos_userbundle
anonymous: true
# Facebook
fos_facebook:
app_url: "http://apps.facebook.com/appName/"
server_url: "http://site.com/"
login_path: ^/login
check_path: ^/login_check$
default_target_path: /
provider: my_fos_facebook_provider
logout:
handlers: ["fos_facebook.logout_handler"]
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
# Facebook
- { path: ^/facebook/, role: [ROLE_FACEBOOK] }
- { path: ^/.*, role: [IS_AUTHENTICATED_ANONYMOUSLY] }
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
config.yaml
fos_facebook:
file: %kernel.root_dir%/../vendor/facebook/src/base_facebook.php
alias: facebook
app_id: 265248730194897
secret: 16b91a34fc986a2d5c5525e118614841 #not the real pass! :)
cookie: true
permissions: [email, user_birthday, user_location]
services:
my.facebook.user:
class: Website\SharedBundle\Security\User\Provider\FacebookProvider
arguments:
facebook: "@fos_facebook.api"
userManager: "@fos_user.user_manager"
validator: "@validator"
container: "@service_container"
from fosfacebookbundle.
Your login path and check path for fos_facebook are wrong. You are giving regexes whereas the only valid values are paths or route names
from fosfacebookbundle.
i just closed the ticket ..
please open new tickets in case you have concrete issues along with example code/configs
from fosfacebookbundle.
10 people cannot make this work and you close the ticket? Really? Try to make it work the code is basic it doesn't need code to be put there, otherwise we wouldn't be so much to have the same problem.
If you search on google there also a lot of people with the same issue... it's not just a configuration problem it's within the bundles.
from fosfacebookbundle.
well it does work for a few of us .. and it seemed like this ticket was just turning into a "yeah i got problems too" .. it would be more useful for us to have focused tickets that include details of the configuration and setup.
from fosfacebookbundle.
From what I have search, only one people made it work. All the other just gave up... as soon as someone make it work I hope they will share the code.
And if the ticket is closed it will only make things harder for them to find it... I mean the issue is still there...
from fosfacebookbundle.
its been a while since i had to set up this bundle from scratch, but afaik a co-worker of mine updated one project using this bundle and had no issues. at any rate .. if you have time. could you setup a github project where we can reproduce the issue?
from fosfacebookbundle.
Sure, I'll try to do it soon.
from fosfacebookbundle.
Hi babour,
While you are working on setting up a non-working example, here is a working setup. Maybe you can test?
Related parts from security.yml
:
providers:
my_userbundle:
id: my_user.my_provider
my_facebook:
id: my_user.my_facebook_provider
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/(login|register/|resetting/.*)$
anonymous: ~
main:
pattern: ^/
form_login:
login_path: /login
check_path: /login_check
provider: my_userbundle
fos_facebook:
login_path: /facebook/login
check_path: /facebook/check
default_target_path: /
provider: my_facebook
logout:
path: /logout
target: /
anonymous: false
access_control:
- { path: ^/_internal, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
- { path: ^/admin/, role: ROLE_ADMIN }
routing.yml
:
_security_check:
pattern: /facebook/check
_security_logout:
pattern: /logout
from fosfacebookbundle.
thx!
actually i just realized that i added Facebook support to my "play ground" a while ago:
https://github.com/lsmith77/symfony-standard/tree/techtalk
doesn't appear to be working anymore as it doesn't seem to actually login me in. maybe you can check if this is the same issue you have.
from fosfacebookbundle.
aersoy: How do you deal with your:
login_path: /facebook/login
check_path: /facebook/check
What do you put in those path, how do you create them?
From what I have seen that's the main issue, no one seem to have figured that out!
from fosfacebookbundle.
ok .. got it to work again. i forgot to install the db schema (since this example integrates with FOSUserBubdle) and there was an outdated call to setAlgorithm
which i just removed
from fosfacebookbundle.
so please install the "techtalk" branch, setup the db schema etc and then try out http://symfony-standard.lo/app_dev.php/liip/facebook
from fosfacebookbundle.
babour: I don't deal with them, FOSFacebookBundle does. You set those up in routing.yml
. You provide them to Facebook API via events in login.twig.html
:
FB.Event.subscribe('auth.login', function(response) { setTimeout(function () { window.location = "{{ path('_security_check') }}"; }, 500); });
FB.Event.subscribe('auth.logout', function(response) { window.location = "{{ path('_security_logout') }}"; });
from fosfacebookbundle.
Until I make an example, here is what I have so far:
http://forum.symfony-project.org/viewtopic.php?f=23&t=37639
from fosfacebookbundle.
Hi babour,
The problem is that, you are not configuring paths correctly. Otherwise, your config seems ok.
from fosfacebookbundle.
Hi there!
@lsmith77 : maybe that's not the right place to ask, but since I started to work with Symfony2 I always was wondering (to be honest, I was not just wondering, I was cursing:) why the security layer has to be so hard to debug. Its still not clear to me. There is a log trace written, but it's far from useful to pin down problems with authentication.
Isn't there a way to say: ok, if you have troubles logging in, switch your logging level to verbose, post your log here, and I tell you what might be wrong?
I mean, people here are spending literally months trying to get this facebook stuff running- maybe we should invest some time to improve the debugging?
It's clear to me that security, auth,... is far from trivial, but there has to be some way to get such things sorted out more quickly IMO.
from fosfacebookbundle.
The problem is that in general events are hard to debug and most of the security layer is tied together via events. That being said afaik there has been a fair bit of work to make debugging events easier in 2.1.
from fosfacebookbundle.
If you have the JMSDebuggingBundle enabled, you get some more useful debugging tools in the Security panel of the profiler (like what firewall matched, which listeners were triggered, or why they were not triggered, etc.).
from fosfacebookbundle.
Hi,
I have been looking into your code and my problem was indeed the path and the creation of the empty function with the right link for the (check_path).
Looking into your code and aersoy's configuration files helped me a lot.
I guess a small documentation on how to configure that part and what function and path to add could help a lot of people.
Thanks for your help guys, particularly lsmith77 and aersoy!
from fosfacebookbundle.
I am having this issue as well.. it seems that @babour has solved this issue and he mentioned the issue was about " the creation of the empty function with the right link for the (check_path)." Can someone please give more details on what this empty function is all about and where/which controller to put it in? @aersoy
from fosfacebookbundle.
I don't have access to the code anymore since I changed employers, but I remember finding an example given by someone on one of my post.
I think you can put this function anywhere, you just have to put the right check_path to it (and maybe redirect it if it doesn't do anything).
from fosfacebookbundle.
@babour what is the function called? can you point me to the correct post
from fosfacebookbundle.
I am sorry, I really don't remember there should be an example of it somewhere because it was on github that I found it...
I think you can name the function as you want you just need to make the right redirection to it...
from fosfacebookbundle.
Its just a local problem. I should add an alias for your localhost in /etc/hosts like:
127.0.0.1 localhost.local
Now, access your app using: localhost.local/app_dev.php/login and it should work fine! =)
from fosfacebookbundle.
Related Issues (20)
- FosFacebookBundle+Varnish HOT 1
- Impossible to update with symfony 2.4 HOT 3
- Allow Symfony 2.4 HOT 5
- Bug in FacebookProvider (trying to register user already existing with same email) HOT 2
- Problem with changing logged users HOT 1
- [Question] Different user types HOT 2
- Routing problem HOT 1
- Bundle compatibility with Symfony 2.4 HOT 2
- Problem with action /login_check on FOSBundle & FOSFacebookBundle
- logout url & session handling
- Permissions HOT 4
- How can i login using facebook and then register and login in our exisitng systems?
- Use FOSFacebook as login in webapplication HOT 4
- Stateless + access token HOT 1
- How to get the cover HOT 1
- Invalid IPv6 configuration on server HOT 2
- How do I override the array that goes into the initialize template? HOT 1
- FacebookProvider uses an unitialized property HOT 5
- Update User Data HOT 1
- Recommended version of FOSFacebookBundle to install? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fosfacebookbundle.