exchangeToken method
Future<Map>
exchangeToken(
- String clientId,
- String clientSecret,
- String code,
- String? codeVerifier,
- String grantType,
- String redirectUri,
override
Implementation
@override
Future<Map> exchangeToken(String clientId, String clientSecret, String code,
String? codeVerifier, String grantType, String redirectUri) async {
final String baseUrl = await getBaseUrl;
var url = Uri.parse("$baseUrl/oauth/token");
var bodyData = {
"client_id": clientId,
"client_secret": clientSecret,
"code": code,
"grant_type": grantType,
"redirect_uri": redirectUri
};
if (codeVerifier != null) {
bodyData.addAll({"code_verifier": codeVerifier});
}
var jsonBody = jsonEncode(bodyData);
var response = await http.post(
url,
headers: {"Content-Type": "application/x-www-form-urlencoded"},
body: jsonBody,
);
var data = jsonDecode(response.body);
return data;
}