http
http copied to clipboard
HTTP authentication fails really need support
guys i really need help on that i want to access this website (http://1.0.0.1/orion/summary.aspx) it redirect me to this website (http://1.0.0.1/orion/login.aspx) i tried many authentications tech but it didn't work all give 401 sample of the code is below
Future getData() async {
// NTLMClient ntlmClient = new NTLMClient(
// domain: "xxa.com",
// workstation: "10.0.0.1",
// username: "user",
// password: "password",
// );
String username = 'user';
String password = 'password';
String basicAuth = 'Basic ' + base64Encode(utf8.encode('$username:$password'));
print(basicAuth);
var client = http.Client();
final loginResponse = await client.post('http://10.0.0.1/Orion/Login.aspx', body: (basicAuth),
headers: <String, String>{'authorization': '$username:$password'});
http.Response response = await client.get('http://10.0.0.1/Orion/SummaryView.aspx',
headers: <String, String>{'authorization': basicAuth},
);
print(loginResponse.statusCode);
print(loginResponse.headers);
print(loginResponse.body);
print(response.statusCode);
print(response.body);
Thanks in Advance
Flutter doctor is OK
Note: Please use triple backticks for code blocks. https://help.github.com/en/articles/creating-and-highlighting-code-blocks
You'll likely get better help from stack overflow for questions like this. It isn't clear whether this is a question about how to use that particular API or if you believe there is a bug in this package in handling those headers or similar...
Are you able to accomplish your goal with curl or some other HTTP utility?
i did post there the same question but no single comment in 2 posts i dont know if its my issue or their issue
I am also facing this issue. @elamir611 Did you found any solution?
I am also facing this issue.
@niketaabnave - can you clarify what, specifically, is the issue?
I am also facing this issue.
@niketaabnave - can you clarify what, specifically, is the issue? This is because the HTTP client converts the header in lower case. To fix this follow below steps : Open your flutter project in android studio,External libraries-> Dart Packages -> http-> io_client.dart ->
search for: request.headers.forEach
replace this with:
request.headers.forEach((name, value) {
ioRequest.headers.set(name, value, preserveHeaderCase: true);
});
I'm not sure that there is a package:http issue here.