signInWithCustomToken method

Future<SignInWithCustomTokenSuccess> signInWithCustomToken(
  1. String customToken
)

Implementation

Future<SignInWithCustomTokenSuccess> signInWithCustomToken(String customToken) async {
  final url = Uri.parse('$firebaseUrl/accounts:signInWithCustomToken?key=$_firebaseKey');
  final jsonRequestBody = jsonEncode({
    'token': customToken,
    'returnSecureToken': true,
  });
  final response = await http.post(
    url,
    headers: {'Content-Type': 'application/json'},
    body: jsonRequestBody,
  );

  if (response.statusCode >= 200 && response.statusCode < 300) {
    return SignInWithCustomTokenSuccess.fromJson(jsonDecode(response.body));
  } else {
    throw WepinError(WepinErrorCode.apiRequestError, 'code: ${response.statusCode} , body: ${response.body}');
  }
}