Thursday, 11 May 2017

Social authentication using Angula2 and Nodejs

In this app I'm running my Node server on port 3000 and my Angular2 server on 4200, I'm trying to login using Facebook and Google auth. I want to be able to login when I click the Facebook or Google button

here are my routes:

app.get('/auth/facebook', passport.authenticate('facebook', {scope: ['email']}));

app.get('/auth/facebook/callback', 
    passport.authenticate('facebook', { successRedirect: '/profile',
        failureRedirect: '/' }));

app.get('/auth/google', passport.authenticate('google', {scope: ['profile', 'email']}));

app.get('/auth/google/callback', 
    passport.authenticate('google', { successRedirect: '/profile',
        failureRedirect: '/' }));

here is my login.component.html

<div id="login-buttons">
    <a class="btn btn-block btn-social btn-facebook">
    <span class="fa fa-facebook"></span> Sign in with Facebook
    </a>
    <a class="btn btn-block btn-social btn-google">
    <span class="fa fa-google"></span> Sign in with Google
    </a>
</div>



via melhirech

No comments:

Post a Comment