requestAuthenticate method
Obtain a set of temporary credentials from the server. http://tools.ietf.org/html/rfc5849#section-2.1
If not callbackURI passed, authentication becomes PIN-based.
Implementation
Future<int> requestAuthenticate(AuthorizationResponse res) async {
final encoding = Encoding.getByName("utf-8");
final body = Uri.encodeFull("login=" + _user.user + "&password=" + _user.password + "&oauth_token=" + res.credentials.token! + "&oauth_callback=oob");
// print("Requisitanto login to: " + _url + 'portal/api/rest/oauth/dologin');
// print("Body: " + body);
Uri dologinURI = Uri.parse(_url + 'portal/api/rest/oauth/dologin');
final http.Response resLogin = await _httpClient.post(
dologinURI,
headers: <String, String>{'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2'},
body: body,
);
// print('Resposta statusCode: ' + resLogin.statusCode.toString());
// print("Resposta body: " + resLogin.body);
if (resLogin.statusCode != 200) {
throw StateError(resLogin.body);
}
return resLogin.statusCode;
}