I have to periodically re-authorise app - why is this?

Hi
We have a website that uses Blackbaud checkout and the Sky apis to connect to the RENXT account.

Every now and again without warning the site connection will fail and we would need to re-authorise the app.

I understand the token has an expiry time limit and as long as the site is getting regular visits that will mean the token keeps getting refreshed.
But in our case it seems that out of the blue we have to re-authorise even while the site was getting regular orders. This is annoying as we only find out when a order fails


Whats the correct way for us to ensure we have a constant connection for our online store
Also should we have some sort of function that checks for connections every hour or so.

Thanks is advance

Comments

  • @Qamar Ramzan

    Hi Qamar,

    To confirm, when you refer to the token, do you mean the access token or the refresh token?

    The refresh token expires in one year, if I recall correctly. The access token has a shorter lifetime.

    You may already know this, but neither token is refreshed automatically just by being used, just to be clear—you have to request a new token (of either kind) when you're ready for one, unless you're using a library that handles that for you.

    In my code, when an access token is needed, we first retrieve the refresh token from our database and check its expiration date. If the date is nearer than a certain threshold, we request a new refresh token and store that.

    At that point, if no error occurred, then we're sure we have a valid refresh token—either because it wasn't expiring soon or because it was but we fetched a new one—so we can request an access token from it.

    Does this help?

    Eric

  • @Qamar Ramzan I'll add this….We get intermittent connection failures with Blackbaud too. In our case, it's not because the token expired, but intermittent errors seemingly on the API end without a clear reason, maybe intermittent outages or maintenance.

    To work around those, we retry with exponential backoff. Our code base is in .NET, so we use the Polly library for that. Not sure if that would help with what you're facing, but thought I'd mention it just in case.

  • @Eric Eskildsen
    Hi Eric,

    Thank you thats been really helpful.
    With regards to the Blackbaud outages, in those cases will that require us to re authorise our app.

    I know it all depends how we have coded our app. I'm not a developer so just wanted a bit more insight before I look into it further.

    In our case we had a site that was running fine for 6 months until we had to re-authorise.

  • @Eric Eskildsen:

    To work around those, we retry with exponential backoff. Our code base is in .NET, so we use the Polly library for that. Not sure if that would help with what you're facing, but thought I'd mention it just in case.

    I think this is what we may be missing

  • @Qamar Ramzan You're very welcome—I hope something here helps.

    In the case of outages, that shouldn't require you to reauthorize, no. That said, I've sometimes gotten mysterious auth errors that went away later, so I wondered if it's possible that it was due to timing. In other words, maybe by the time you reauthorized, Blackbaud had resolved an auth error on their end. I'm not ruling out an expired refresh token, just brainstorming.

  • @Qamar Ramzan I'd say a retry mechanism is worth checking out, definitely. It solved many issues with the Blackbaud API for me.

    In my code today, nearly every Blackbaud API call is decorated with a retry policy. It retries 3 times, waiting an increasing number of seconds between each retry. Blackbaud errors decreased quite a bit after that.

  • @Qamar Ramzan Just an FYI that our SKYLib•NET SKY API SDK and code library manages all your token handling and call retries, and even optimizes your call-rate automatically. You just add it to your Visual Studio project as a reference and away you go. It supports all publicly-released APIs and endpoints. And it's available in a free, call-rate-limited version and a subscription, full-rate version.

    Let me know if you want more information.

    Steve Cinquegrana | CEO and Principal Developer | Protégé Solutions