Skip to content

Conversation

@chrisroos
Copy link
Contributor

We've seen a small number of exceptions in Experience CS which are caused by a 401 response from Editor API. I'm fairly confident these are occurring when the access token used to make the request to Editor API has expired. My hypothesis is that the token is valid at the time the request comes into Experience CS (and therefore the auto refresh behaviour isn't triggered) but is invalid by the time we make the request to Editor API. This change reduces the risk of this happening by refreshing the token if it expires in the next 60 seconds.

We've seen a small number of exceptions in Experience CS[1] which are
caused by a 401 response from Editor API. I'm fairly confident these are
occurring when the access token used to make the request to Editor API
has expired. My hypothesis is that the token is valid at the time the
request comes into Experience CS (and therefore the auto refresh
behaviour isn't triggered) but is invalid by the time we make the
request to Editor API. This change reduces the risk of this happening by
refreshing the token if it expires in the next 60 seconds.

[1]: https://github.com/RaspberryPiFoundation/experience-cs/issues/914
@github-actions
Copy link

github-actions bot commented Jul 17, 2025

Test coverage: 100.0%

floehopper
floehopper previously approved these changes Jul 17, 2025
I've gone with a patch version bump because I think the changed
behaviour is closer to a bug fix than it is to backward-compatible
additional functionality (minor version bump) or to a
backward-incompatible change (major version bump).

NOTE. I've manually bumped the version in the individual gemfile.lock
files because running `bundle update --conservative rpi_auth` resulted
in updates to a number of other unrelated Gems and I didn't want to have
to consider those in this PR.
@chrisroos chrisroos force-pushed the refresh-token-before-expiry branch from dbfa89e to 10350f7 Compare July 17, 2025 11:23
@chrisroos
Copy link
Contributor Author

Thanks, @floehopper - can you review it again now that I've also bumped the version and updated the CHANGELOG, please?

@chrisroos chrisroos merged commit 2c5cedb into main Jul 21, 2025
13 checks passed
@chrisroos chrisroos deleted the refresh-token-before-expiry branch July 21, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants