I am using HWIOAuthBundle in a Symfony2 project
How can i get the User email from Facebook, i followed the documentation , it asks me only the first time for permissions although i configured it to rerequest them. See also this issue
hwi_oauth:
http_client:
timeout: 19
verify_peer: false
ignore_errors: false
max_redirects: 1
firewall_names: [main]
resource_owners:
facebook:
type: facebook
client_id: xxxxxxx
client_secret: xxxxxxxxxxxxxxxxx
scope: "email"
infos_url: "https://graph.facebook.com/me?fields=id,name,email,picture.type(square)"
paths:
email: email
profilepicture: picture.data.url
options:
display: 'popup'
auth_type: rerequest # Re-asking for Declined Permissions
And the result of var_dump always returns null
This is because of the unverified email address, Check out your email after approving the permission, and try with another account.
Related
I have found a few topics related to the same issues, but the solution for them was a miss-configuration of the smtp settings.
I am using symfony 3.0 and latest FOSUserBundle. My config settings are:
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
resetting:
email:
template: email/password_resetting.email.twig
registration:
form:
type: AppBundle\Form\RegistrationType
confirmation:
enabled: true
from_email:
address: registration#site.com
sender_name: 'Our Team'
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
port: "%mailer_port%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I am able to send other emails from the same project, using the same swiftmailer settings.
I have checked the web developer tool and the email is prepared for sending
Web profiler - email area
The registration email is not received in the inbox or spam folders.
Could you let me know if I have missed anything in the configuration files that prevents the registration email from being sent?
Thanks,
Lucia
I found a solution for my problem. The registration email address had to be the same as the one used for the swiftmailer username settings. Having it set to a different email address did not work for me.
I'm building a symfony REST Api in which I'm trying to get HWIOAuthBundle, FOSUserBundle and LexikJWTBundle working all together.
I followed this gist for the HWIOAuthBundle/FOSUserBundle integration.
Now I'm getting the facebook login form when hitting the /login route. But after submition I get this error :
[2/2] HttpTransportException: Error while sending HTTP request
[1/2] RequestException: Failed to connect to graph.facebook.com port 443: Bad access
INFO - Matched route "hwi_oauth_service_redirect".
CRITICAL -
Uncaught PHP Exception HWI\Bundle\OAuthBundle\OAuth\Exception\HttpTransportException:
"Error while sending HTTP request"
at C:\myProject\vendor\hwi\oauth-bundle\OAuth\ResourceOwner\AbstractResourceOwner.php
line 257
DEBUG -
Notified event "kernel.request" to listener
"Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke".
...
I'm now looking for help about this. Or any other way to get those bundles to work together.
config.yml :
hwi_oauth:
# list of names of the firewalls in which this bundle is active, this setting MUST be set
firewall_names: [auth]
http_client:
timeout: 10000
verify_peer: false
max_redirects: 1000
ignore_errors: false
fosub:
username_iterations: 300
properties:
# these properties will be used/redefined later in the custom FOSUBUserProvider service.
facebook: facebook_id
# an optional setting to configure a query string parameter which can be used to redirect
# the user after authentication, e.g. /connect/facebook?_destination=/my/destination will
# redirect the user to /my/destination after facebook authenticates them. If this is not
# set then the user will be redirected to the original resource that they requested, or
# the base address if no resource was requested. This is similar to the behaviour of
# [target_path_parameter for form login](http://symfony.com/doc/2.0/cookbook/security/form_login.html).
# target_path_parameter: _destination
# an optional setting to use the HTTP REFERER header to be used in case no
# previous URL was stored in the session (i.e. no resource was requested).
# This is similar to the behaviour of
# [using the referring URL for form login](http://symfony.com/doc/2.0/cookbook/security/form_login.html#using-the-referring-url).
# use_referer: true
# here you will add one (or more) configurations for resource owners
resource_owners:
facebook:
type: facebook
client_id: {id}
client_secret: {secret}
scope: ""
infos_url: "https://graph.facebook.com/me?fields=name,email,picture.type(square)"
options:
display: popup
security.yml :
firewalls:
auth:
pattern: ^/api/minisite/user/auth
anonymous: true
stateless: true
form_login:
check_path: /api/minisite/user/auth/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
username_parameter: username
password_parameter: password
require_previous_session: false
oauth:
resource_owners:
facebook: "/api/minisite/user/auth/facebook/login/check-facebook"
login_path: /api/minisite/user/auth/facebook/login
check_path: /api/minisite/user/auth/login_check
failure_path: /api/minisite/user/auth/facebook/login
oauth_user_provider:
#this is my custom user provider, created from FOSUBUserProvider - will manage the
#automatic user registration on your site, with data from the provider (facebook. google, etc.)
service: my_user_provider
logout: true
anonymous: true
access_control:
- { path: ^/api/minisite/user/auth, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api/minisite, roles: IS_AUTHENTICATED_FULLY }
Configure this in your config.yml file.
hwi_oauth:
http_client:
verify_peer: false
Setting this allows you to turn off SSL verification.
I got the same problem using HWI on localhost. I don't know, but if it's your case, try to upload your work on a server. The reason of this issue is that your are using the port 80, but facebook need that you use the port 443 or use ipv6.
Hope this help
I am configuring Fosuserbundle and HWIOAuth Bundle to Login from Facebook and Google.
issue i am facing is:
When i try to login a user through google account , when he is not already logged in , as i enter credentials of Google and press login it shows me error
No route found for GET/
Or some times
No route found for GET/ ( from wwww.mysite.com/app_dev.php/en/home/ )
it does store information of user (e.g Email , user name etc) in databases , when i go to home page i find my self logged in.
When i try to log in a user who is already logged in with hi google account , it works perfectly.
I am stuck with this... Step by step followed This documentation. Everything is working perfectly except this.
You help would be appreciated.
config.yml
hwi_oauth:
#this is my custom user provider, created from FOSUBUserProvider - will manage the
#automatic user registration on your site, with data from the provider (facebook. google, etc.)
#and also, the connecting part (get the token and the user_id)
connect:
account_connector: my_user_provider
# name of the firewall in which this bundle is active, this setting MUST be set
firewall_name: main
fosub:
# username_iterations: 30
properties:
# these properties will be used/redefined later in the custom FOSUBUserProvider service.
facebook: facebook_id
google: google_id
resource_owners:
facebook:
type: facebook
client_id: "xxxxxxxxxxxxxxxxxxxxxxx"
client_secret: "xxxxxxxxxxxxxxxxxxxxxxx"
scope: ""
google:
type: google
client_id: "xxxxxxxxxxxxxxxxxxxxxxx"
client_secret: "xxxxxxxxxxxxxxxxxxxxxxx"
scope: "https://www.googleapis.com/auth/userinfo.email
--------------------security.yml------------
firewalls:
main:
pattern: ^/
form_login:
check_path: /login_check
login_path: /login
provider: fos_userbundle
# always_use_default_target_path: true
# default_target_path: /%locale%/home
oauth:
resource_owners:
facebook: "/login/check-facebook"
google: "/login/check-google"
login_path: /login
failure_path: /login
oauth_user_provider:
#this is my custom user provider, created from FOSUBUserProvider - will manage the
#automatic user registration on your site, with data from the provider (facebook. google, etc.)
service: my_user_provider
logout:
path: /logout
target: /%locale%/home
anonymous: ~
-----------------routing.yml------------
fos_user_security:
resource: "#FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "#FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "#FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "#FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "#FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
#HWIOAuthBundle routes
hwi_oauth_security:
resource: "#HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /login
hwi_oauth_connect:
resource: "#HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /login
hwi_oauth_redirect:
resource: "#HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /login
facebook_login:
pattern: /login/check-facebook
google_login:
pattern: /login/check-google
I installed FOS UserBundle for user login/register. The thing is that after registering, it redirects me on the "../register/check-email" page where it has the well-known message that a mail with the activation link has been sent to the user's email, but I don't receive any e-mail.
My config.yml file has this code for the fos_user:
fos_user:
db_driver: orm
firewall_name: main
user_class: IngrijireMedicalaAcasa\AppBundle\Entity\User
registration:
form:
type: ingrijiremedicalaacasa_appbundle_registration
confirmation:
enabled: true
service:
mailer: fos_user.mailer.default
from_email:
address: noreply#anytext.com
sender_name: any text
Do I have to do any other configuration somewhere?
I mention I tried to change the address "noreply#anytext.com" with my own valid mail address.
I changed even the parameters.yml with my mail details but it still doesn't work.
Oh, and I try to send the mail from my localhost.
I hope you guys know what's the solving to my problem. I think it's a small thing that I don't see, I don't know or I forgot to do it.
try this : (works if your email is gmail (mailer_transport)
#app/config/config.yml
//
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
# host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: IngrijireMedicalaAcasa\AppBundle\Entity\User
registration:
confirmation:
from_email:
address: your.email#gmail.com
sender_name: Any Text
enabled: true
service:
mailer: fos_user.mailer.twig_swift
in your config_dev.yml :
//
assetic:
use_controller: true
swiftmailer:
transport: gmail
username: your.email#gmail.com
password: your password
in app/config/parameter.yml:
//
mailer_transport: gmail
//
I have successfully integrated my fos facebook bundle with my symfony2 application.But no email address in the resulting data.Is it possible to get email address of the logged in person using fos facebook bundle?
Have you setted the permission?
fos_facebook:
alias: facebook
app_id: xxxxxxxxxxx
secret: xxxxxxxxxxx
cookie: true
permissions: [email, user_hometown, user_location]