Skip to content

Error handling with refreshTokenGrant #874

Description

@aza547

What happened?

Hello,

Thanks for the library. I'm a bit unsure of the right way to handle errors with the refreshTokenGrant method. I'm not sure if this is a bug so hope you will forgive the issue if not. Ultimately I want to do this...

try {
  await refreshTokenGrant(...)
} catch (error) {
  if (error.intermittent) {
     // retry later
  } else {
     // delete refresh token and log user out
  }
} 

The docs don't make it clear on what refreshTokenGrant throws however.

I had a poke about in the source (read errorHandler) and I can see that it is rethrowing errors from the oauth4webapi library in many cases (so I could try install that library and catch those errors) but there is another ClientError type too.

So my question ultimately is what is the right way to do this? And assuming you agree with the above the request is for the docs to make that clear. Please tell me if I'm doing something stupid.

Many thanks

Version

v6.8.4

Runtime

Select an option

Runtime Details

Node 24

Code to reproduce

See above.

Required

  • I have searched the issues tracker and discussions for similar topics and couldn't find anything related.
  • I agree to follow this project's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions