manjeshpv / node-oauth2-server-implementation

Using oauth2-server: 3.0.0-b2 & Supports MongoDB, MySQL, PostgreSQL, MSSQL & SQLite
216 stars 103 forks source link

Error 503: `accessTokenExpiresAt` must be a Date instance while #18

Open md-ray opened 7 years ago

md-ray commented 7 years ago

Hi, I've successfully get access token using Password Grant. When I try to use the access token to access secured pages, I got this error: { "statusCode": 503, "status": 503, "code": 503, "message": "Server error: accessTokenExpiresAt must be a Date instance", "name": "server_error" }

I'm using this library with Mongo Model, using Dockerized Mongo DB Version 3.4.4

Any idea how to solve this?

r2DoesInc commented 7 years ago

You must have
accessTokenExpiresAt: { type: Date }, defined in your OAuthTokens model

gxrahul commented 7 years ago

'accessTokenExpiresAt' is being stored as 'expires'. Modify the getAccessToken method in mongo-models.js and add this line in "then" callback: token.accessTokenExpiresAt = token.expires;

DzhideX commented 4 years ago

Capture

I'm just putting my solution here if anyone with a similar problem stumbles upon it. All of the values in my token sql table were seperated by an underline. The return here expects the values to be in camelCase. Hope this helps someone!