Web Framework
  • Introduction
  • Chapter1: Build Front-End Develope environment
    • 1.1.Install Sublime Text3 and packages
    • 1.2.Sublime plugin
      • 1.2.1.Package install control
      • 1.2.2.Emmet
      • 1.2.3.HTML-CSS-JS Prettify
      • 1.2.4 .SublimeLinter
      • 1.2.5.Install Sublime text Build system
      • 1.2.6.Pretty JSON
      • 1.2.7.SublimeHighlight
      • 1.2.8.SublimeAStyleFormatter
  • Chapter2: Angular.js
  • Chapter3: 3rd Party API
    • 3.function
  • Chapter4: React.js
    • 4.1.Introduction
    • 4.2.Getting started
    • 4.3.JSX
    • 4.4.life cycle
    • 4.5.Data flow: prop vs. prop.children, state
    • 4.6. Layout, Event Handing
    • 4.7.Using JQuery in React
    • 4.8.Using D3.js in React
    • 4.9.Dynamic Routing
  • Chapter5: Webpack
  • Chapter6: web driver IO & mocha
  • Chapter7: RWD
    • 7.1.利用Sass & media query在不使用框架下完成RWD
  • Chapter8: React native
Powered by GitBook
On this page
  • This section contain the following items:
  • 1.Use Facebook's OAuth API to login
  • 2016-09-11
  • reference:

Was this helpful?

Chapter3: 3rd Party API

This section contain the following items:

  1) Use Facebook's OAuth

1.Use Facebook's OAuth API to login

2016-09-11

  1)Register yor APP to Facebook from : 
    http://developers.facebook.com/setup/, you can get APP_ID
  2)Get secret from : 
    https://developers.facebook.com/apps/656891331154404/dashboard/取得client id及secret
  3)Estalish a new Node Express project
  4)Edit app.js :
    //var routes = require('./routes/index');
    //var users = require('./routes/users'); 
    //app.use(express.static(path.join(__dirname, 'public')));
    app.use('/public', express.static(path.join(__dirname, 'public')));
    app.use('/bower_components', express.static(path.join(__dirname + '/bower_components')));
    routes(app);
    console.log("start listening");
    app.listen(8080);

  5)Edit routes/index :
    /*
      router.get('/', function(req, res, next) {
      res.render('index', { title: 'Express' });
      });
    */
    //module.exports = router;

    module.exports = function(app) {
      //provide main page
      app.get('/', function(req, res, next) {
        res.sendfile('./public/main.html'); // load the single view file 
        //res.render('candidate', { title: 'Express' });
      });    
    };
  6)Copy example code from: https://developers.facebook.com/docs/facebook-login/web/
  7)Create/public/main.html and paste example code
  8)Start Node Http server
  9)Open broswer and paste the following URL:
    https://www.facebook.com/dialog/oauth?
    client_id={your APPID}&
    scope=email,user_birthday&
    redirect_uri=http://localhost:8080

    then broswer will ask user to athourize this app to get user's Fb information
    And you can get user's code
  10)Open broswer and paste the following URL to get user's access token:
    https://graph.facebook.com/oauth/access_token?
    client_id={your APPID}&
    redirect_uri=http://localhost:8080&
    client_secret={your secret}&
    code={code}

reference:

  1.網站利用 Facebook 帳號登入 (使用 OAuth):http://sweeteason.pixnet.net/blog/post/40581580-%E7%B6%B2%E7%AB%99%E5%88%A9%E7%94%A8-facebook-%E5%B8%B3%E8%99%9F%E7%99%BB%E5%85%A5-(%E4%BD%BF%E7%94%A8-oauth)
  2.網站利用 Facebook 帳號登入 (Javascript SDK):http://sweeteason.pixnet.net/blog/post/37284400
  3.facebook: https://developers.facebook.com/docs/facebook-login/web/
  4.facebook api quick start:https://developers.facebook.com/quickstarts/656891331154404/?platform=web
PreviousChapter2: Angular.jsNext3.function

Last updated 5 years ago

Was this helpful?