strongloop / loopback-component-oauth2

oAuth 2.0 server for LoopBack
http://www.strongloop.com
Other
62 stars 63 forks source link

Making this work with Loopback 3.x alpha #35

Closed Octopixell closed 8 years ago

Octopixell commented 8 years ago

Hi All,

I've been trying to get this package to play nice with Loopback 3.0.0-alpha.1 but it's been a bit of a struggle.

In 3.x app.loopback.urlencoded is undefined so I've replaced it with BodyParser (https://www.npmjs.com/package/body-parser), which allowed me to actually start up the project.

After that no routes or models are actually defined inside the API. So I've added the models to my model-config.json file and used datasource.automigrate() to make sure I have the proper tables and all.

So far I've been able to get the API started without errors and migrate the models to the DB. The problem is that none of the routes are defined, so I really can't do anything with it.

Is it remotely possible to make this work with 3.x? Thanks!

Octopixell commented 8 years ago

To make the issue more clear, routes don't seem to work I get this error:

Unhandled error for request GET /oauth/authorize: Error: There is no method to handle GET /oauth/authorize
    at restUrlNotFound (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/strong-remoting/lib/rest-adapter.js:345:17)
    at Layer.handle [as handle_request] (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:312:13)
    at /Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:330:12)
    at next (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:271:10)
    at jsonParser (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/body-parser/lib/types/json.js:100:40)
    at Layer.handle [as handle_request] (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:312:13)
    at /Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:330:12)
    at next (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:271:10)
    at urlencodedParser (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/body-parser/lib/types/urlencoded.js:88:40)
    at Layer.handle [as handle_request] (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:312:13)
    at /Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:330:12)
    at next (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:271:10)
    at /Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/strong-remoting/lib/rest-adapter.js:235:5
    at Layer.handle [as handle_request] (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:312:13)
    at /Users/marco/TaxiID/dispatchapi.io/api.dispatchapi.io/node_modules/loopback/node_modules/express/lib/router/index.js:280:7
Octopixell commented 8 years ago

Ok, I got this working now. Was a simple mistake that we kept overseeing. Endpoints registered to root rather than /api. Something with long days and more coffee 😄

What I can't get working at the moment is posting to the endpoints, I'm not sure what exactly the post body should look like and I can't seem to find any documentation on that, but maybe I'm blind hehe..

If anybody could help, that'd be awesome.