-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Provide default implementation for Basic / Bearer authentication #2143
Comments
I’m somewhat reluctant to include this. I expect credentials to not usually be available as a simple string, but instead stored encrypted somewhere. Or used to prompt the user. I'm going to close this, but I could be convinced. |
I have a react-native app that really needs this. It makes use of a java library that has a REST API which needs basic auth (user name and password in the url) -> https://user:pass@localhost:8888/... There's no option to provide the auth as a header when supplying an image with one of these urls. |
For basic auth you can just set the header manually. See the Credential class to build a basic auth header. |
Thanks. The user of this is the Facebook Fresco api, so I'll have to try and get that changed. Out of interest what's the reason for not wanting to include it? |
Do Chrome and Firefox still implement that? As far as I can tell this behavior is obsolete. |
They do. The reason I need it is that I'm making use of an http service that requires an auth header, even for loading image content. And there's no way I can specify anything about the transport layer I'm using. I'm writing in javascript (react-native), which calls react-native java code, which calls the Facebook fresco api, which calls OkHttp. :( |
Which versions? How'd you confirm that they support this? I used whatever version I have on my Mac and I entered a URL like |
Hmm, not sure why you're not seeing it. Here's what I see when I hit my server with this URL in chrome
Note the Authorisation header in the request |
I've dug a little deeper and it not obvious from the Chrome output whats happening here. From the source code of this server I'm using I can see that if the Authorisation header is not present it returns a 401 along with Found this:
|
Ahh, so the authentication isn’t pre-emptive. I missed that. |
Can you hook up an OkHttp interceptor? |
I'm not familiar with the code base but I could try. Actually, there's one right at the top of this discussion. Will that work? |
Yup! |
Hey @swankjesse - did this ever get implemented? |
Hi - did this get implemented??? |
No. |
Any reason why? Its part of the http spec, no? |
Hi,
we all know that authentication can be handled using
Authenticator
s and/orInterceptor
s. Would it be useful to provide default implementations for Basic auth and Bearer token auth. Guess this could be common tasks that are performed by many client applications.Impl for interceptor could look like this, passing the credentials in the constructor ... the authenticator could use something of a Callback interface so that the application can provide its credentials
wdyt?
The text was updated successfully, but these errors were encountered: