Aithusa
02/06/2023, 4:05 AMdart
Error: FormatException: Refresh token endpoint must start with http or https
dart
SuperTokens.init(apiDomain: "http://localhost:8000");
nkshah2
02/06/2023, 4:10 AMnkshah2
02/06/2023, 4:10 AMnkshah2
02/06/2023, 4:14 AMAithusa
02/07/2023, 4:45 PMdart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
AuthWrapper.init();
API.ping();
runApp(const App());
}
dart
import 'package:supertokens_flutter/supertokens.dart';
Aithusa
02/07/2023, 4:46 PMdart
class AuthWrapper {
static const String apiDomain = "http://localhost:3000";
static Future<bool> login(String email, String password) async {
Uri uri = Uri.parse("$apiDomain/login");
await http.post(uri, body: {
"formFields": [
{"id": "email", "value": email},
{"id": "password", "value": password}
]
}).then((value) {
Map<String, dynamic> data;
});
return true;
}
static Future<Status> signUp(String email, String password) async {
Uri uri = Uri.parse("$apiDomain/signup");
Status status = Status(success: true, message: "Ok");
if (AuthWrapper.checkEmailExists(email)) {
return Future(
() => Status(success: false, message: "The email already exists"));
}
await http.post(uri, body: {
"formFields": [
{"id": "email", "value": email},
{"id": "password", "value": password}
]
}).then((value) {
Map<String, dynamic> data;
try {
data = jsonDecode(value.body);
} on FormatException catch (e) {
status =
Status(success: false, message: "An internal error has occured");
return;
}
if (data['status'] == 'Ok') {
status = Status(success: true, message: "Signed up for an account");
}
});
return status;
}
static bool checkEmailExists(String email) {
Uri uri = Uri.parse("$apiDomain/signup?email=$email");
return false;
}
/**
* Current user id of logged in user
*/
static Future<String> getUserId() {
return SuperTokens.getUserId();
}
static void signOut() {
SuperTokens.signOut();
}
static void init() {
print("initializing authentication server");
SuperTokens.init(apiDomain: "http://localhost:3000");
}
}
Aithusa
02/07/2023, 4:46 PMdart
import 'package:http/http.dart';
import 'package:supertokens_flutter/http.dart' as http;
class API {
static String baseUrl = "http://localhost:3000/";
const API();
static Future<void> ping() async {
Response res = await http.get(Uri(path: baseUrl + "/ping"));
print(res.body);
print("health check");
}
}
nkshah2
02/08/2023, 5:23 AMdart
import 'package:supertokens_flutter/supertokens.dart';
void main() {
SuperTokens.init(apiDomain: "http://localhost:3000");
runApp(const MyApp());
}
with
yaml
supertokens_flutter: ^0.0.1
Works fine for me. Can you clear pub cache and re-install dependencies and check? Also version 0.1.0 of the SDK was released recently, you could try upgrading to that and trying againnkshah2
02/08/2023, 5:30 AM