refreshTokens method
Refreshes a user's tokens with its refreshToken
Implementation
Future<QuickbooksOauth2Tokens> refreshTokens({
required String refreshToken,
}) async {
// Gets the config values
var config =
await _configService.getConfiguration(isProduction: _isProduction);
//Refreshes the tokens
return await http.post(Uri.parse(config.tokenEndpoint), headers: {
'content-type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ${getBasicToken()}'
}, body: {
"grant_type": "refresh_token",
"refresh_token": refreshToken,
}).then((response) async {
switch (response.statusCode) {
case 200:
var body = jsonDecode(response.body) as Map<String, dynamic>;
return QuickbooksOauth2Tokens.fromMap(body);
default:
throw AlfredException(500, 'Quickbooks error');
}
});
}