node.js - client_id undefinded on grant_type=password (oauth2orize) -
I am making an API in nodes with oauth2orize and passport, but when I ask for token, the client_id parameter is unsupported is.
Oauth2orize:
server.exchange (oauth2orize.exchange.password (function (customer, user name, password, scope, callback) {console.log (client); / / It has tried with client_id, clientId, id ... username: username , Password: password Why is the client parameter undefined?
Thank you very much
less like this There is a need to create a passport strategy:
var passport = requires ('passport'), client password string = ('passport-oauth2-client-password') Strategy; passport.use ("client password", new client password (work (customer ID, customer service, done) {Clients.findOne ({clientId: clientId}, function (error, client) {if (mistake) Returns Done (mistake) if returned (! Client) (empty, wrong) if (! Client. Trusted client) returned (empty, incorrect) (client.clientSecret == clientSecret) returned (blank, customer) and returned (blank, wrong)}); })); Then you need to force your route so that your request will be thrown out of this strategy: (with express)
app post ( '/ Url', passport authentication ('client password'), server.token ()); Finally, to request your token, the post parameter should be: - client_id
- client_secret
- Username
- Password
- Grant Type: Password
Comments
Post a Comment