Login to NodeBB using Facebook access token?

NodeBB Plugins
  • Hey guys,

    I'm developing an app for my forum.

    So far, I've managed to get the Facebook Login in a native way:

    Facebook App opens and user authorizes the app.

    It returns the access_token and the user info.

    My question: How can I use the access_token and send it to NodeBB in order to:

    a ) login if the user has registered in the past
    b ) create an account

    I'm using julian's SSO-Facebook plugin and all my users are registered via Facebook.

    Edit: I'm checking the sso-facebook plugin and passport.js to see if I can (somehow) send the response I get to /auth/facebook/callback

     

    I've also found: https://github.com/drudge/passport-facebook-token

    But I'm having trouble figuring out how to implement it on NodeBB's /src/routes/authentication.js

    Any clue?

    @julian @psychobunny ?

  • Ok, so far I've got it to work using passport-facebook-token and changing julian's sso-facebook plugin:

    	FacebookTokenStrategy = require('passport-facebook-token'),
    

    and changing:

    		passport.use(new passportFacebook({
    

    to

    		passport.use(new FacebookTokenStrategy({
    

    Also:

    		strategies.push({
    			name: 'facebook',
    			url: '/auth/facebook',
    			callbackURL: '/auth/facebook/callback',
    			icon: constants.admin.icon,
    			scope: 'email, user_friends'
    		});
    

    to

    		strategies.push({
    			name: 'facebook-token',
    			url: '/auth/token',
    			callbackURL: '/auth/token/callback',
    			icon: constants.admin.icon,
    			scope: 'email, user_friends'
    		});
    

    I'm able to log into my account but I get this error:

    0_1499144571635_Screen Shot 2017-07-04 at 00.02.37.png

    Why is the route not found?


Suggested Topics


  • 0 Votes
    3 Posts
    2k Views

    As far as I know there is no eCommerce module for NodeBB.

  • 5 Votes
    10 Posts
    3k Views

    @Scuzz. For the moment for it to work on 0.7 on my install I have removed the hooks for usersettings, but if I have any time soon I will try to make those work also. This at the moment was shown that maybe someone will make use of the code before I will make it stable.

  • 0 Votes
    3 Posts
    2k Views

    @Mega Thanks Mega!
    I know this can work, I expect the formal release for this.😏

  • 1 Votes
    6 Posts
    3k Views

    @Scuzz said:

    @psychobunny *Now we can watch Twitch Plays Pokemon on our forum!

    can we? 😄

  • 3 Votes
    10 Posts
    5k Views

    Here is my version of it. Check out the result on UEX start page. Feel free to use Google translate

    <style> #nyheter .date { float: right; } #nyheter img { display: block; height: auto; margin: 10px 0px; max-width: 100%; } #nyheter iframe { max-width: 100%; } </style> <table id="nyheter" class="table table-striped"></table> <script type="text/javascript"> var rss_urls = [ 'http://www.fz.se/core/rss/fznews_rss20.xml', 'http://loading.se/rss.php?type=news', 'http://www.eurogamer.se/?format=rss&type=news', 'http://www.gamereactor.se/rss/rss.php?texttype=4' ]; var news_items = []; var protocol = document.location.protocol === "file:" ? "http:" : document.location.protocol; for (var i = 0; i < rss_urls.length; i++) { var rss_url = rss_urls[i]; jQuery.ajax({ type: "GET", url: protocol+'//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q=' + encodeURIComponent(rss_url), dataType: 'json', success: function(data) { values = data.responseData.feed.entries; var list = '', count = 0; jQuery.each(values, function(index, item) { if (count >= 5) { return; } var news_item = {}; var pubDate = item.publishedDate; var date = new Date(pubDate); var month = date.getMonth < 10 ? date.getMonth() : "0" + date.getMonth(); news_item.date = date.getFullYear() + "-" + month + "-" + date.getDate() + " " + date.getHours() + ":" + date.getHours(); news_item.datetime = date.getTime(); news_item.link = item.link; news_item.title = item.title; news_item.content = item.content; news_items.push(news_item); count++; }); update_table(); } }); } function update_table() { news_items.sort(function(a, b) { var keyA = new Date(a.datetime), keyB = new Date(b.datetime); // Compare the 2 dates if (keyA < keyB) return 1; if (keyA > keyB) return -1; return 0; }); var list = ""; for (var i = 0; i < news_items.length; i++) { var item = news_items[i]; list += "<tr><td><a href='" + item.link + "' target='_blank'>" + item.title + "</a><span class='date'''>" + item.date + "</span> <br/> <span>" + item.content + "</span><br/></td></tr>"; } jQuery('#nyheter').html(list); } </script>

    Sharing is caring ....