Azard / egg-oauth2-server

:star2: OAuth2 server plugin for egg.js based on node-oauth2-server
MIT License
178 stars 45 forks source link

TypeError: app.oauth.token is not a function #14

Closed jeremy16601 closed 6 years ago

jeremy16601 commented 7 years ago

集成后一直报这个错误,检查了下,没配置错啊,有知道怎么回事的吗

Azard commented 7 years ago

app.oAuth2Server.token() 之前的文章是 1.x 版本的,现在 2.x 了

jeremy16601 commented 7 years ago

app.oAuth2Server.token() 这个也一样的提示。 @Azard

jeremy16601 commented 6 years ago

TypeError: Cannot read property 'token' of undefined @Azard 变成这个了

jeremy16601 commented 6 years ago

D:\nodejs-Project\Exposure\node_modules\egg\lib\application.js:40 throw e; ^

TypeError: Cannot read property 'token' of undefined at module.exports.app (D:\nodejs-Project\Exposure\app\router.js:6:44) at AppWorkerLoader.loadFile (D:\nodejs-Project\Exposure\node_modules\egg-core\lib\loader\egg_loader.js:269:30) at AppWorkerLoader.loadRouter (D:\nodejs-Project\Exposure\node_modules\egg-core\lib\loader\mixin\router.js:15:10) at AppWorkerLoader.load (D:\nodejs-Project\Exposure\node_modules\egg\lib\loader\app_worker_loader.js:41:10) at new Application (D:\nodejs-Project\Exposure\node_modules\egg\lib\application.js:36:19) at Object. (D:\nodejs-Project\Exposure\node_modules\egg-cluster\lib\app_worker.js:13:13) at Module._compile (module.js:569:30) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3) at Function.Module.runMain (module.js:605:10) at startup (bootstrap_node.js:158:16) at bootstrap_node.js:575:3 [Mon Oct 09 2017 11:05:32 GMT+0900 (中国标准时间)] [cfork:master:27504] worker:26408 disconnect (exitedAfterDisconnect: fals e, state: disconnected, isDead: false)

Azard commented 6 years ago

你有创建 // {app_root}/app/extend/oauth.js 这个文件吗

jeremy16601 commented 6 years ago

恩,按照你教程,还有git上的demo试了。这个错误提示 @Azard

Azard commented 6 years ago

在 egg 初始化之后输出 app.oAuth2Server 看看输出,可能是初始化顺序的问题。 要不然回退到 1.x 版本,用法简单一些。

jeremy16601 commented 6 years ago

已解决,感谢作者。