Jump to content
  • 0

REST API OAuth token refresh routine became unstable


ArturCz

Question

Hey,

I'm working with IG's OAuth authentication process to keep an authenticated session in my REST API client. As IG's OAuth access token expires every 60 seconds, I refresh the access token with the provided refresh token every 55 seconds to keep a valid access token at all times (having a look at network traffic in IG's REST API companion, it looks like it's done exactly the same way there).

However, recently the POST /session/refresh-token v1 interface became very unstable, often throwing error.security.invalid-details or error.security.authentication.timeout. As I use an exponential backoff retry mechanism behind the requests, the requests sometimes works after 3 or 4 retries (after 10ms to 100ms delay before I trigger the next retry). However, sometimes the requests don't succeed at all and I'm forced to create a new session with the POST /session v3 interface (which has worked as a last resort for now).

Even if I have recovery mechanisms in place to ensure a valid access token, it's a bit odd that POST /session/refresh-token v1 fails this often recently. Session management is the most basic layer of an API and it shouldn't be this unstable.

I should mention that I run two distinct processes which maintain their own authenticated sessions. But even with two sessions I'm doing 2 non-trading requests per 55 seconds which is well within IG's REST API quotas.

It looks like the POST /session/refresh-token v1 interface might be overloaded on IG's side for some reason recently. If this is the case it might be helpful that I call attention to this issue here. If this isn't caused by an overload on IG's side I would appreciate some feedback what I should do different (which would ultimately imply that it is not done in the very correct way in IG's REST API companion as well).

I would appreciate if there is some feedback regarding this issue!

Best regards,

ArturCz

Link to comment

1 answer to this question

Recommended Posts

  • 0

After a week this issue seems to be resolved for now, session refreshes are not failing frequently anymore. Seems like the cause of this issue was in IG's backend but got resolved. From the outside I would guess that the backend was overloaded somehow or that there was some internal server logic error. I will revive this thread again if the issue comes back.

This shows: if you are planning to use an API for automated trading, make sure to try to automatically resolve basic issues with ALL tools available to prevent the trading operation from failing. Fortunately, I had/have the mechanisms in place to handle most quirks of IG's API to literally force the API to function. Otherwise my trading operation would probably have been unusable during the last week.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • image.png

  • Posts

    • Staying stuck in gloomy bearish seasons has never been the right approach in the market, so when the market isn’t so favourable I tend to always explore various events to stay profitable. Events don’t get more fun and rewarding at same time than spinning events, so when I saw 100% Spin hot coins events on Bitget with Apple sets and other rewards up for grabs, I just had to quickly jump on it. Participation is pretty simple too, one just has to register, make a net deposit using deposit methods to get spins, trade copy or futures trading for more spins, then spin for the rewards. One exciting thing about the event is its extended duration, lasting from August 28 to September 25, giving participants ample time to spin and get incentivized. A fun and rewarding event if you ask me, only be sure to follow the rules to stay eligible.
    • Today, the U.S. Congress is making history by holding its first-ever hearing on decentralized finance (DeFi). This landmark event could have significant implications for the DeFi sector, including the price of Uniswap (UNI). Key Details of the Hearing Date and Time: The hearing will take place today at 10 a.m. ET. Focus: The session is titled “Decoding DeFi: Breaking Down the Future for Decentralized Finance.” Participants: The Financial Services Subcommittee on Digital Assets, Financial Technology, and Inclusion will lead the discussion. Notable witness Rebecca Rettig, Chief Legal and Policy Officer at Polygon Labs, will be among those present. Impact on Uniswap Price Uniswap's price is currently showing a bullish reversal pattern, despite ongoing scrutiny from the U.S. Securities and Exchange Commission (SEC). With Uniswap's price approaching a crucial 139% breakout zone, the hearing could be a turning point. As of now, UNI is down 0.54% in the last 24 hours, trading at $6.62, according to Coinpedia Markets data. Why This Hearing Matters The hearing represents a significant shift in how DeFi is perceived by U.S. lawmakers. Republican Congressman French Hill has criticized the Biden-Harris Administration for using "rule-making and enforcement actions" that, he believes, stifle DeFi innovation. As the DeFi landscape in the U.S. is under intense scrutiny, Uniswap stands out as a major player, particularly since it attracted more U.S. users than other countries in August 2024, according to Statista data. Looking Ahead If the hearing results in a favorable policy shift, Uniswap's price could see a substantial increase. Market conditions will play a critical role, but if they remain favorable, Uniswap might be on the brink of a 150% breakout rally. As Congress delves into DeFi, the future of Uniswap and the broader DeFi sector could be set for a significant transformation.
    • I recently came across an interesting event on Bitget called "100% Spin Hot Coins! Win your Campus Lucky Draw and Apple Sets." It seems like a promotional campaign where participants can win various digital currencies like PEPE, ****, BGB, KAS, TRX, WIF, and FLOKI, along with Apple products. To join, you need to register and complete the KYC verification process. The event is available to users from specific regions, including the UK, Canada, Australia, and several European countries. The total prize pool is 50,000 USDT, and rewards are given on a first-come, first-served basis. If you're into crypto and enjoy participating in such events, this might be worth checking out. Just make sure to read the terms and conditions carefully before diving in.
×
×
  • Create New...
us