Update partner refresh token logic to fetch new access token when expired
Context
- Follow-on to https://github.com/pixiebrix/pixiebrix-extension/issues/6603
- API calls should automatically fetch a new access token using the refresh token if the access token is expired
- Similar to how we refresh PKCE tokens
This issue will be closed in 7 days unless the stale label is removed, or a comment is added to the issue.
@grahamlangford this issue is likely non-trivial and so should have a quick implementation sketch in GitHub to ensure we've addressed the considerations
The partner JWT is used to call our server (in addition to the control room). So we'd need to account for the refresh logic in:
- RTK base query (in the base query itself, or in the client used to make the request)
- Non-RTK calls to our API (e.g., using a transformer?). The method we use to solve this will depend on whether we're using ky or axios
Most likely we'll want to add a handler to getApiClient as that would cover both RTK Query and other calls: https://github.com/pixiebrix/pixiebrix-extension/blob/71182b2a15b942cc70d63587dc8ce5d59411d8cc/src/data/service/apiClient.ts#L91-L91.
Related code
- https://github.com/pixiebrix/pixiebrix-extension/blob/71182b2a15b942cc70d63587dc8ce5d59411d8cc/src/background/partnerIntegrations.ts#L248-L248
- https://github.com/pixiebrix/pixiebrix-extension/blob/71182b2a15b942cc70d63587dc8ce5d59411d8cc/src/background/partnerIntegrations.ts#L182-L182
- https://github.com/pixiebrix/pixiebrix-extension/blob/71182b2a15b942cc70d63587dc8ce5d59411d8cc/src/data/service/baseQuery.ts#L79-L79
@grahamlangford this issue is likely non-trivial and so should have a quick implementation sketch in GitHub to ensure we've addressed the considerations
Agreed. Note to whoever picks this up, please draft an implementation sketch and communicate it on #engineering for review.
@grahamlangford why is this on in the "Support Chrome MV3" epic? Seems unrelated to MV2 vs. MV3. Should this be in the AA epic instead?
@grahamlangford why is this on in the "Support Chrome MV3" epic? Seems unrelated to MV2 vs. MV3. Should this be in the AA epic instead?
Probably a mistake. I agree. Added to the AA epic.