Skip to content

feat: Expose http status code on request_async / request methods #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
c-thiel opened this issue Feb 18, 2025 · 2 comments
Open

feat: Expose http status code on request_async / request methods #302

c-thiel opened this issue Feb 18, 2025 · 2 comments

Comments

@c-thiel
Copy link

c-thiel commented Feb 18, 2025

I am using oauth2 under the hood to authenticate clients.
If an authentication request fails, I don't want to exit immediately, but potentially retry.

Retries should only happen on 5XX error codes, not 4XX.

Currently RequestTokenError does not expose the status code of the underlying request, which makes it hard to categorize the root cause of the failure.

It would be really helpful if RequestTokenError would expose the underlying status code for all error variants.

I ran into this issue specificly for the client credential flow, but I am sure other flows will benefit too.

@LorenzoLeonardo
Copy link
Contributor

You can implement a custom HttpClient that implements an AsyncHttpClient or SyncHttpClient so that you can have more control of the return status codes. Just set the defaults to false.

@attilaolah
Copy link

I was looking through the default implementation today, and hoping I don't have to implement that trait myself. But I couldn't figure out an efficient way to send tokens to the introspect endpoint without rolling a custom client.

My issue is somewhat different though (sorry for hijacking this thread), but what I'm trying to do seems very simple: I exchange my client ID & secret for an access token, then I'd like to use that access token to aouthorise calls I make to the introspect URL (sending client tokens).

Now, I could create a long-lived client that holds the "Authorization: Bearer …" header that I got, but eventually my token will expire, and I'll need to renew it, and at that point it seems silly to have to re-create the whole client just for the sake of injecting a new header.

It would be much nicer to inject the Authorization header into the request we get from the IntrospectionRequest itself, but there doesn't seem to be an obvious way to do that, or at least I haven't found one.

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

No branches or pull requests

3 participants