Open vladimirdolzhenko opened 4 years ago
I tried to write my own OAuthAuthProvider
based on the existing providers in io.ktor.client.features.auth.providers
which seems to work but with the restriction that I can only retry a request once.
But I might need to retry the request multiple times when using a refresh token:
So my question is: How can I retry the request multiple times in an io.ktor.client.features.auth.AuthProvider
?
PS: When my provider is working, I'm happy to contribute it here.
Hi, @hardysim. You can try using ‘HttpSend’ feature. You can add interceptor there and retry request multiple times(See HttpRedirect feature as the example)
I've managed to alter the Auth
feature to behave a bit like OkHttp's Authenticator
.
This means, AuthProvider.addRequestHeaders()
can return a nullable request (instead of just altering it) and Auth
will execute()
the request if one is returned (and stops when null
is returned). This way, no circuitBreaker
is needed and the provider can retry the request as often as it likes to.
I'm going to post a PR with my changes. Maybe the team will accept my solution and you'll get my OAuthAuthProvider
with it.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
To crosslink the progress:
OAuthAuthProvider
but was only merged into a private branch by @e5lAuthScheme.Bearer
which is needed by OAuthAuthProvider
but is not merged yetIs there any update regarding this issue?
Please follow https://youtrack.jetbrains.com/issue/KTOR-5232/
Subsystem Client
Is your feature request related to a problem? Please describe. There is no oauth2 client authentication, and especially JetBrains Space auth
Describe the solution you'd like I'd like to have smth like
actually to authenticate in Space I have to do smth like
and later on for each query use
Motivation to include to ktor OAuth2 is quite common auth way