pixiebrix-extension icon indicating copy to clipboard operation
pixiebrix-extension copied to clipboard

Update partner refresh token logic to fetch new access token when expired

Open grahamlangford opened this issue 2 years ago • 5 comments

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

grahamlangford avatar Oct 12 '23 13:10 grahamlangford

This issue will be closed in 7 days unless the stale label is removed, or a comment is added to the issue.

github-actions[bot] avatar Feb 10 '24 00:02 github-actions[bot]

@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

twschiller avatar Mar 30 '24 17:03 twschiller

@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 avatar Apr 01 '24 14:04 grahamlangford

@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?

twschiller avatar Apr 04 '24 11:04 twschiller

@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.

grahamlangford avatar Apr 04 '24 13:04 grahamlangford