http icon indicating copy to clipboard operation
http copied to clipboard

HTTP authentication fails really need support

Open elamir611 opened this issue 6 years ago • 6 comments

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

elamir611 avatar Oct 17 '19 10:10 elamir611

Flutter doctor is OK

elamir611 avatar Oct 17 '19 10:10 elamir611

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?

natebosch avatar Oct 17 '19 22:10 natebosch

i did post there the same question but no single comment in 2 posts i dont know if its my issue or their issue

elamir611 avatar Oct 22 '19 08:10 elamir611

I am also facing this issue. @elamir611 Did you found any solution?

niketaabnave avatar Jul 01 '21 14:07 niketaabnave

I am also facing this issue.

@niketaabnave - can you clarify what, specifically, is the issue?

natebosch avatar Jul 15 '21 22:07 natebosch

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);
});

niketaabnave avatar Jul 19 '21 10:07 niketaabnave

I'm not sure that there is a package:http issue here.

brianquinlan avatar Jan 13 '24 00:01 brianquinlan