apollographql / apollo-kotlin

:rocket:  A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform.
https://www.apollographql.com/docs/kotlin
MIT License
3.75k stars 651 forks source link

Does apollo support okhttp3 Authenticator? #6191

Closed igorwojda closed 2 weeks ago

igorwojda commented 2 weeks ago

Question

Apollo documentation mentions support of OkHttp interceptors as a way to easily add an "Authorization" header to HTTP requests.

I wonder if Apollo also supports okhttp Authenticator as a way to refresh auth token and retry the request? (after my initial trials I don't think this is the case but I want to double check)

BoD commented 2 weeks ago

This was answered on Slack - for the record, the issue was that this particular server replied with 200 in case of auth errors, thus OkHttp Authenticator doesn't work. A possible solution is to implement an ApolloInterceptor. Closing for now.

github-actions[bot] commented 2 weeks ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Kotlin usage and allow us to serve you better.

martinbonnin commented 2 weeks ago

the issue was that this particular server replied with 200 in case of auth errors

FWIW, the "200 ok" days are counted and if a server supports application/graphql-response+json, it's soon-ish fine to use whatever HTTP status code makes sense. See https://github.com/apollographql/apollo-kotlin/pull/6170 and https://graphql.github.io/graphql-over-http/draft/#sec-Processing-the-response