requestTokenCredentials method
Future<AuthorizationResponse>
requestTokenCredentials(
- Credentials tokenCredentials,
- String verifier
Obtain a set of token credentials from the server. http://tools.ietf.org/html/rfc5849#section-2.3
Implementation
Future<AuthorizationResponse> requestTokenCredentials(Credentials tokenCredentials, String verifier) async {
final Map<String, String> additionalParams = <String, String>{'oauth_verifier': verifier};
final AuthorizationHeaderBuilder ahb = AuthorizationHeaderBuilder();
ahb.signatureMethod = _platform.signatureMethod;
ahb.clientCredentials = _clientCredentials;
ahb.credentials = tokenCredentials;
ahb.method = 'POST';
ahb.url = _platform.tokenCredentialsRequestURI;
ahb.additionalParameters = additionalParams;
// print("Requisitanto token to: "+_platform.tokenCredentialsRequestURI);
// print("Authorization: "+ahb.build().toString());
Uri tokenCredentialsRequestURI = Uri.parse(_platform.tokenCredentialsRequestURI);
final http.Response res = await _httpClient.post(tokenCredentialsRequestURI, 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);
}