php - Symfony3 Facebook Login - redirect_uri URL gets converted to relative -
i trying implement facebook login web-app. here facebookconnect.php
<?php namespace vendor\giftbundle\controller; use sensio\bundle\frameworkextrabundle\configuration\route; use symfony\bundle\frameworkbundle\controller\controller; use symfony\component\httpfoundation\request; use symfony\component\httpfoundation\response; use symfony\component\routing\generator\urlgeneratorinterface; use symfony\component\routing\generator\urlgenerator; class facebookconnectcontroller extends controller { /** * @route("/connect/facebook", name="connect_facebook") */ public function connectfacebookaction(request $request) { // redirect facebook $redir = $this->generateurl('connect_facebook_check', array(), urlgeneratorinterface::absolute_url); $facebookoauthprovider = $this->get('app.facebook_provider'); $url = $facebookoauthprovider->getauthorizationurl([ // these default scopes 'scopes' => ['public_profile', 'email'], 'redirect_uri' => [$redir], ]); return $this->redirect($url); } /** * @route("/connect/facebook-check", name="connect_facebook_check") */ public function connectfacebookactioncheck() { // not reached! } } when hit button triggers connectfacebookaction function fb error the redirect_uri url must absolute. it's ignores absolute url have given him in parameters.
what doing wrong?
edit: authorization url changing in circumstances or remains same app? hardcode in until figure out how fix this?
edit2: figured out why url relative , not absolute. here services configuration:
services: app.facebook_provider: class: league\oauth2\client\provider\facebook arguments: - clientid: %facebook_app_id% clientsecret: %facebook_app_secret% graphapiversion: v2.8 redirecturi: "@=service('router').generate('connect_facebook_check', {}, true)" how do absolute url generation route in services?
are using version 1.x of league/oauth2-client (you can check in composer.lock)? ignores redirect_uri in getauthorizationurl , uses 1 pass in constructor. if you're using version, change definition app.facebook_provider read
redirecturi: "@=service('router').generate('connect_facebook_check', {}, 0)" note 0 instead of true. the urlgeneratorinterface constants have changed in 2.8.
Comments
Post a Comment