-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
auth params in image urls don't work in android #7200
Comments
I would say it probably gets striped out at some point -> if you could do some debugging by putting breakpoints here and there in this method https://github.com/facebook/react-native/blob/master/Libraries/Image/RCTImageLoader.m#L261 - it will probably tell you more. If not - no worries, I'll try to look into that when I get to the office in the morning. Sounds like a small bugfix, is it iOS or Android? |
I've narrowed it down to an android bug, but I can't find the problem. I think what's supposed to happen when you specify a username and password in the url, is that an authorization header gets created with a base64 encode of the credentials. At least that's what it looks like my browser does. It seems that the Android java client isn't doing this. I've stepped though the code and nowhere does it explicitly remove that text from the url. I guess its just ignoring it and not creating the auth header. |
It might be the OkHttp library not supporting basic auth: square/okhttp#2143 Or maybe the fresco code needs a couple of lines adding to it. Help! |
It could also be the image size, when you console logged the url, does it show the url you're expecting? If it does, you can check the adb logs to see if it gives you an image too big error. adb logcat -t 500 to see the logs. If you do see the error, the image will need to be resized |
Its not the image size. OkHttp doesn't honour the Basic auth pattern, and Fesco doesn't put the auth headers in (in android at least). I don't know which is incorrect, maybe both? The problem doesn't happen on IOS. An incorrect image size wouldn't result in a 401. |
I think that it's going to be addressed in the OkHttp library. square/okhttp#2143 |
Feel free to close and thanks for digging into that. There's an issue in this repo about okhttp upgrading (there are some blockers on FB end). So if that ends up being fixed by them and released in next version - please reference it :) |
Its not being fixed by them unfortunately. I'm not sure what do do now. There's a proposed solution but for some reason they won't implemented it. Could it be added to RN? Ideally, I'd like to be able to add auth header props to the See: #7791 and facebook/fresco#1459 |
Ah, looks like support for adding headers to image requests has been added to Fresco in com/facebook/imagepipeline/backends/okhttp3/OkHttpNetworkFetcher.java on Jul 6th. Looks like version 13 got released since then so I guess this change is in. But... I think RN is using Fresco version 11 still. |
Yeah, this is just pending on that Fresco upgrade and getting it in. I'm going to close this issue because I think we are already sufficiently tracking problems with the old fresco, thanks for reporting this! |
If I have an image url like http://**admin:pass@**host/image.jpg it appears that the username and password get stripped from it by the component. Is this by design?
The text was updated successfully, but these errors were encountered: