Search code examples
phpsymfonyhwioauthbundle

Pass parameter HWIOAuthbundle symfony2


I'm trying to pass a GET parameter from my Facebook and Google login button, that I've set up using HWIOAuthbundle. I've looked at this question: To path the parameter to OAuth facebook login by symfony2/HWIOAuthBundle, however I didn't quite understand how he managed to get it working. He mentions using referer, which I don't anything about - and I don't have enough reputation to post a comment on that question...

I was thinking something like this:

<a href="{{ path('google_login',{'datakey':1}) }}">Link</a>

But how do I retrieve it in my FOSUBUserProvider? I appreciate all help!


Solution

  • I finally managed to get it working. However, I am not sure it is the best way to do it. It's a quick fix until I find a more proper solution.

    When someone enters my website with the datakey variable as a $_GET parameter, I set a cookie with the value. When the user logs in, the FOSUBUserProvider checks whether the datakey cookie is set; if it is, it will do its thing.

    This is the best I can do for now, as I haven't managed to succeed sending parameters through the hwioauthbundle and into my FOSUBUserProvider.

    If someone finds a better solution, let me know!