如果 Client ID 和 Client Secret 正確, 訪問github授權url時,會得到一個token
獲得token即驗證成功.
代碼實現:
index.html
<html><head><scriptsrc="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script><scriptsrc="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><divid="app"><ahref="http://localhost:3000/github/login">login with github</a></div></body></html>
目標
將開發中經常遇見的問題寫在這里方便查詢.
使用Koa創建一個簡單的服務器
const Koa require("koa");
const app new Koa();
app.listen(3000, () >{console.log("[server] Server is running at http://localhost:3000")
})使用koa2-cors解決…