requestTemporaryCredentials 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<AuthorizationResponse> requestTemporaryCredentials([String? callbackURI]) async {
callbackURI ??= 'oob';
final Map<String, String> additionalParams = <String, String>{'oauth_callback': callbackURI};
final AuthorizationHeaderBuilder ahb = AuthorizationHeaderBuilder();
ahb.signatureMethod = _platform.signatureMethod;
ahb.clientCredentials = _clientCredentials;
ahb.method = 'POST';
ahb.url = _platform.temporaryCredentialsRequestURI;
ahb.additionalParameters = additionalParams;
// print("Requisitanto token to: "+_platform.temporaryCredentialsRequestURI);
// print("Authorization: "+ahb.build().toString());
Uri temporaryCredentialsRequestURI = Uri.parse(_platform.temporaryCredentialsRequestURI);
final http.Response res = await _httpClient.post(temporaryCredentialsRequestURI, headers: <String, String>{'Authorization': ahb.build().toString()});
// print('Resposta statusCode: '+res.statusCode.toString());
// print("Resposta body: "+res.body);
if (res.statusCode != 200) {
throw StateError(res.body);
}
final Map<String, String> params = Uri.splitQueryString(res.body);
return AuthorizationResponse.fromMap(params);
}