CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. -- % of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you understand how CFDs work and whether you can afford to take the high risk of losing your money.

Refresh_token can only be used once

Hello team,

I try to use refresh_token in https://www.darwinex.com/data/darwin-api to generate new access token.
It seems it can only use once, the 2nd time to request access_token, it shows bellow error:

{'error_description': 'Persisted access token data not found', 'error': 'invalid_grant'}

url = 'https://api.darwinex.com/token'

More information: the sampe method is not working anymore https://github.com/darwinex/darwin-api-tutorials/blob/ee87ce33fb83835369e348ef51982666ec65c8e1/PYTHON/AUTH/dwx_oauth2_p3.py#L20

Hello @fountainhead,

Using the refresh token to generate new access tokens not only generates a new access token but also a new refresh token, revoking the existing one. It is not always happening, but most of the times.
After using the refresh token grant successfully, if you access the https://www.darwinex.com/data/darwin-api , it should display the updated credentials for you.

I see. thank you for your response!

Hello,

I think the refresh_token is expired after couple days, isn’t it?

Because after some days, I need to go to https://www.darwinex.com/data/darwin-api/ to generate it again because the old one not work anymore.

Hello @fountainhead,

The refresh token expires after using it for a new access token or after 23 hours and 30 minutes at the moment. Certainly, once it is expired the only way to get new tokens is by entering into https://www.darwinex.com/data/darwin-api/ and requesting the generation of tokens again. In order to keep accessing the API in an automated way, you can use the refresh token grant to retrieve the new access token and … a new refresh token.

got it! thank you for your response.

For other system like Google Oauth2, usually fresh token seems not expiring though.