Git Product home page Git Product logo

oauth2-fb-tutorial's Introduction

oAuth2-fb-tutorial

setup

  1. 首先,先在 facebook for developers 註冊應用程式

  2. 在此專案目錄下建立 .env, 並且將你的資料填入

facebook_client_id=
facebook_secret_id=
redirect_uri=
facebook_console_id=

facebook_client_id 以及 facebook_secret_id 在註冊完的應用程式設定中可以找到

fb_dev

分別為 應用程式編號 以及 應用程式密鑰

redirect_uri 則填入 ip:3000/facebook/callback ,這邊要注意的是臉書不允許用 http,所以無法只接用 localhost, 這邊推薦大家用 ngrok 來將一個外網網址映射到 localhost:3000/callback/facebook

ngrok

例如我的 ngrok 幫我映射的 URL 為 https://7bfbb3ed.ngrok.io

redirect_uri 就填入 https://7bfbb3ed.ngrok.io/facebook/callback

除了在 .env 填入以外, 也要記得在剛才應用程式設定中填入 有效的 OAuth 重新導向 URI 之中

fb-dev2

最後一個 facebook_console_id 則是自己的 facebook 帳戶 token

取得方式為:

curl -X GET "https://graph.facebook.com/oauth/access_token?client_id={id}&client_secret={id}&grant_type=client_credentials"

client_idclient_secret 與 .env 的前兩個欄位相同

  1. npm i (安裝所需套件)

  2. npm run server (此時瀏覽 localhost:3000 即可)

demo

demo

oauth2-fb-tutorial's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.