createOAuthToken method
dynamic
createOAuthToken({})
Authenticate with the Fortnite API
Implementation
dynamic createOAuthToken({
required String grantType,
required String grantData,
String tokenType = "eg1",
required String authClient,
}) async {
HttpResponse res = await _client.http.post(
url: Endpoints().oauthTokenCreate,
headers: {
"Authorization": "basic $authClient",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent":
"Fortnite/++Fortnite+Release-18.21-CL-17811397 Android/11",
},
body: "grant_type=$grantType&$grantData&token_type=$tokenType",
);
if (res.success) {
return res.data["access_token"];
} else {
if (res.error?["errorCode"] ==
"errors.com.epicgames.account.invalid_account_credentials") {
_client.sendInvalidAccountError();
throw Exception("Your account credentials are invalid");
}
throw Exception(res.error?["errorMessage"] ?? "Unknown error");
}
}