node-oauth2-server icon indicating copy to clipboard operation
node-oauth2-server copied to clipboard

how to issue refresh token?

Open sinamiandashti opened this issue 13 years ago • 12 comments

how the refresh token can be created?

or what is the url to issue refresh token?

or anything about it ... plz help

sinamiandashti avatar Jul 01 '13 05:07 sinamiandashti

Hi Placebo,

As noted in the Readme, the refresh token implementation is not 100% finished yet.

Currently, refresh_tokens are being issued alongside access_tokens however the ability to use them has not been implemented. Now you've raised it, hopefully we can sort it reasonably soon (unless of course you'd be willing to have a go yourself)

thomseddon avatar Jul 01 '13 06:07 thomseddon

Have added support + filled out the Readme, give me a shout if you have any problems

thomseddon avatar Jul 01 '13 09:07 thomseddon

did u update the npm package version ?

how to use it ? how client should request a new token by the refresh token?

sinamiandashti avatar Jul 01 '13 20:07 sinamiandashti

Yes, we're on 1.4 now.

Good point, I will add some more general documentation about requesting tokens this week, general idea is that you POST to /oauth/token with client creds, the refresh token and grant_type=refresh_token On 1 Jul 2013 21:23, "sina miandashti" [email protected] wrote:

did u update the npm package version ?

how to use it ? how client should request a new token by the refresh token?

— Reply to this email directly or view it on GitHubhttps://github.com/nightworld/node-oauth2-server/issues/3#issuecomment-20307729 .

thomseddon avatar Jul 01 '13 20:07 thomseddon

so me in my client ... if receive the msg 'token expired' from your module ... then post the expired token and refresh token to oauth/token then your module give me new token?

sinamiandashti avatar Jul 01 '13 20:07 sinamiandashti

I've done some doc updates including adding a new example: https://github.com/nightworld/node-oauth2-server#example-using-the-password-grant-type

thomseddon avatar Jul 02 '13 08:07 thomseddon

generate refresh token : any examples ?

viksat7 avatar Apr 13 '18 07:04 viksat7

gettting new token set using grant type refresh token does not seem to be working . Any inputs ?

kruti-thukral avatar Nov 12 '18 20:11 kruti-thukral

@kruti-thukral I think that there is a bug at the (currently) stable version 3.0.1, in line 103 of lib/grant-types/refresh-token-grant-type.js. There is a hardcoded client.id instead of client.clientId. Apparently, it is fixed in tag v4.0.0-dev.1 (but wrong again in tag v4.0.0-dev.2).

I'm not sure about what will be the definitive change; the property at client definition (clientId -> id) or the property at the mentioned condition (id -> clientId), so I'm not making any pull request (yet).

I have an example project using version 3.0.1 with refresh_token grant type working (with a fix for that bug), maybe it can help you :) node-oauth2-server-example

pedroetb avatar Nov 18 '18 19:11 pedroetb

@pedroetb - I dont see any issue with the lib code . I have directly used oauth2-server version 3.0.1 and I have the refresh token working fine.Thanks for the input though . After your comment, i realised something was going wrong with my client id and was a bug in my code . Fixing that resolved the issue.

kruti-thukral avatar Nov 19 '18 23:11 kruti-thukral

@kruti-thukral I think that there is a bug at the (currently) stable version 3.0.1, in line 103 of lib/grant-types/refresh-token-grant-type.js. There is a hardcoded client.id instead of client.clientId. Apparently, it is fixed in tag v4.0.0-dev.1 (but wrong again in tag v4.0.0-dev.2).

I'm not sure about what will be the definitive change; the property at client definition (clientId -> id) or the property at the mentioned condition (id -> clientId), so I'm not making any pull request (yet).

I have an example project using version 3.0.1 with refresh_token grant type working (with a fix for that bug), maybe it can help you :) node-oauth2-server-example

@pedroetb I tried your example,still error when use refresh_token type,got below error

curl http://localhost:3000/oauth/token \
> -d "grant_type=refresh_token" \
> -d "client_id=application" \
> -d "client_secret=secret" \
> -d "refresh_token=5de9099aa1925063d05b75c4cca4377c9f9982ea" \
> -H "Authorization: Basic YXBwbGljYXRpb246c2VjcmV0" \
> -H "Content-Type: application/x-www-form-urlencoded"
{"statusCode":400,"status":400,"code":400,"message":"Unauthorized client: `grant_type` is invalid","name":"unauthorized_client"}

leapit avatar Sep 19 '19 10:09 leapit

@leapit discussed and fixed at https://github.com/pedroetb/node-oauth2-server-mongo-example/issues/7

pedroetb avatar Sep 22 '19 23:09 pedroetb