oauthjs / koa-oauth-server Goto Github PK
View Code? Open in Web Editor NEWComplete, compliant and well tested module for implementing an OAuth2 Server/Provider with koa in node.js
Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with koa in node.js
Version 2.4.0 of node-oauth2-server seems to have introduced a breaking change. I'll provide more information as soon as I can.
TypeError: Cannot read property 'set' of undefined
at Grant.sendResponse (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/grant.js:471:5)
at run (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:15:14)
at /Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:17:7
at Grant.saveRefreshToken (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/grant.js:430:29)
at run (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:15:14)
at /Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:17:7
at Grant.generateRefreshToken (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/grant.js:412:66)
at run (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:15:14)
at /Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:17:7
at /Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/grant.js:401:5
at /Users/johnwehr/Projects/test-project/models/oauth2-model.js:62:7
The offending function:
/**
* Create an access token and save it with the model
*
* @param {Function} done
* @this OAuth
*/
function sendResponse (done) {
var response = {
token_type: 'bearer',
access_token: this.accessToken
};
if (this.config.accessTokenLifetime !== null) {
response.expires_in = this.config.accessTokenLifetime;
}
if (this.refreshToken) response.refresh_token = this.refreshToken;
this.res
.set('Cache-Control', 'no-store') // Line 471
.set('Pragma', 'no-cache')
.jsonp(response);
if (this.config.continueAfterResponse)
done();
}
See the commit: thomseddon/node-oauth2-server@c19719e
I try set and get session in jquery . i try this
for(var i=0;i<m.length;i++)
{
if (m[i] !== null)
{
master.row.add({
" Type": m[i][1],
"Frequency": m[i][2],
})
}
}
$.session.set("Type ", m[i][1]);
$.session.set("Frequency ", m[i][2]);
i also add session.js but this show error on console
Uncaught TypeError: Cannot read property 'set' of undefined(โฆ)
var headerToken = this.req.get('Authorization'),
getToken = this.req.query.access_token,
postToken = this.req.body ? this.req.body.access_token : undefined;
console.log('getToken:',getToken);
console.log('headerToken:',headerToken);
console.log('postToken:',postToken);
getToken: undefined
headerToken:
postToken: b80ba6196e247b0fae2d9226d2c722a5d01ae90b
methodsUsed: 2
question:why headerToken != undefined
KoaOAuthServer.prototype.authenticate = function() {
var server = this.server;
return function *(next) {
var request = new Request(this.request);
var response = new Response(this.response);
try {
this.state.oauth = {
token: yield server.authenticate(request,response)
};
} catch (e) {
return handleError.call(this, e);
}
yield* next;
};
};
Hi,
i noticed that the request hangs if the app have a previously defined body parser.
app.use( betterBody );
app.post( '/oauth/token', oauth.grant() ); // hangs here
but switching the position make my app work:
app.post( '/oauth/token', oauth.grant() );
app.use( betterBody );
Tests not passing with [email protected]
One would think that would be optional since user/password are being used to auth and the fact that the secret would be exposed? New to oauth, apologies if I'm mistaken!
With the release of Koa 2 this project needs to be refactored to be promise based.
I currently have a PR open for these changes: #47
Can we get an update on the state of this project?
Remove the body parser for 2.x and use koa-body-parser
for 1.x
I noticed that this repo deps on a fork version of node-oauth2-server. And some of its unitTest failed.
So I have the following in my model:
getAccessToken: function(bearerToken, cb) {
cb(null, {
expires: expires
userId: 1
});
}
and then:
app.get('/secret', app.oauth.authorise(), function *(next) {
console.log(this.req.user);
this.body = 'secret';
});
but this.req.user is undefined... am I doing this incorrectly?
Thanks!
Hi:
Just curious when v2 will be available on npmjs? as it currently v1.0.1
will v1.0.1 work with [email protected]?
I wasn't able to get memory/model.js to work with both [email protected]/[email protected]
I managed to get it going using an older version of memory/model.js with callbacks and saveAccessToken instead of saveToken
Thanks
J.
using version: 1.0.1
Following the examples exactly, even resorted to just copy/pasting. Doesn't seem to work at all when using generators for the model. Switched to functions, that take a callback and everything is fine.
Hello,
Project looks great but I see that the version here in github is not published on npm, last one is 1.01 which is not working: oauth2-server included does not like generators.
A new release needs to be made with all of the changes from the past few months
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.