Refresh Token if the current token is invalid

Created at 17 Mar 2021, 09:33
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
BU

budda_dan2020

Joined 10.09.2020

Refresh Token if the current token is invalid
17 Mar 2021, 09:33


Hi,

I am running an c# program which uses Open API.

As far as I know, the access token is valid for a given time being.

When the access token is no longer valid, I should use the refresh token in order to get a new valid token.

1) Which API message should I use and how?

2) If I get new access token and new refresh token thru this message response, am I able to still operate trading action?

3) How can I know if the current access token is no longer valid?

I am looking forward to reply.

Thanks in advance.


@budda_dan2020
Replies

amusleh
17 Mar 2021, 10:18

RE:

budda_dan2020 said:

Hi,

I am running an c# program which uses Open API.

As far as I know, the access token is valid for a given time being.

When the access token is no longer valid, I should use the refresh token in order to get a new valid token.

1) Which API message should I use and how?

2) If I get new access token and new refresh token thru this message response, am I able to still operate trading action?

3) How can I know if the current access token is no longer valid?

I am looking forward to reply.

Thanks in advance.

1. For refreshing token you have to use the ProtoOARefreshTokenReq message

2. After updating the refresh token you have to re-authorize the trading accounts by sending new ProtoOAAccountAuthReq message and you have to use the new token for all future requests

3. You can use the token expiry time to check for expiry, and if your token expired you will receive a ProtoOAAccountsTokenInvalidatedEvent message


@amusleh