getAccountFromAuthCode method
Implementation
Future<OAuthAccount> getAccountFromAuthCode(
WebAuthenticator authenticator) async {
if (tokenUrl?.isEmpty ?? true) throw new Exception("Invalid tokenURL");
var postData = await authenticator.getTokenPostData(clientSecret);
var resp = await httpClient.post(Uri.parse(tokenUrl!),
headers: {
"Accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded"
},
body: postData);
var map = convert.json.decode(resp.body);
var result = OAuthResponse.fromJson(map);
var account = OAuthAccount(identifier,
created: DateTime.now().toUtc(),
expiresIn: result.expiresIn,
idToken: result.idToken,
refreshToken: result.refreshToken,
scope: authenticator.scope,
tokenType: result.tokenType,
token: result.accessToken);
return account;
}