I'm trying to create a user name and password in my Social Network app, and this keeps popping up.
class AppwriteConstants { static const String databaseID = '64df6c6d91........'; static const String projectID = '64df63.........'; static const String endPoint = 'http://My_Ip_Address/v1'; //static const String endPoint = 'http://localhost:80/v1'; }
I've tried both endPoint versions and i keep getting the same issue. Hope someone can help me!
can you show how do you intialise the client?
using port 80 or anything else?
import 'package:appwrite/appwrite.dart'; import 'package:appwrite/models.dart' as models; import 'package:communify_app/core/core.dart'; import 'package:communify_app/core/providers.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:fpdart/fpdart.dart';
final authAPIProvider = Provider((ref) { final account = ref.watch(appwriteAccountProvider); return AuthAPI(account: account); });
abstract class IAuthAPI { FutureEither<models.User> signUp({ required String email, required String password, }); }
class AuthAPI implements IAuthAPI { final Account _account;
AuthAPI({required Account account}) : _account = account;
@override FutureEither<models.User> signUp({ required String email, required String password, }) async { try { final models.User createdUser = await _account.create( userId: ID.unique(), email: email, password: password); return right(createdUser); } on AppwriteException catch (e, stackTrace) { return left( Failure(e.message ?? 'An unexpected error occurred', stackTrace), ); } catch (e, stackTrace) { return left( Failure(e.toString(), stackTrace), ); } } }
i used createdUser because the Appwrite updated their files and removed Account from models.dart
This is fine, I want to see the client code, how did you initalized the client object? And how are you passing it to the Account class
FYI, use three back ticks to format your code
sorry about this.
i've got an appwrite_client.dart file
import 'package:appwrite/appwrite.dart'; import 'package:communify_app/constants/appwrite_constants.dart';
class AppwriteClient { static late Client _client; static late Account account;
static void initialize() { _client = Client(); _client .setEndpoint(AppwriteConstants.endPoint) .setProject(AppwriteConstants.projectID);
account =
Account(_client); // Initializing the account instance with the client.
}
static Client get client => _client; }
just confirming again,
did you install appwrite on port 80? on localhost?
or there was another port used?
on my local env, I usually use some other port like:
static const String endPoint = 'http://localIpAddress:8990/v1';
i installed it on 80
localhost 80, yes correct
does using http://localhost open appwrite's dashboard on your browser? Chrome, Safari?
Yes it does.
opens up Brave (chrome)
even when i use my IP address, it opens up as well.
using the ip works on phone's browser to open the dashboard?
Yes it does.
Im trying to delete my Appwrite to start over.
But that also is giving me issues. Lol.
ash@lightone.io role(users) missing scope (users.write)
I think there is some issue with this code. I think your endpoint is not being set thus to this error. To confirm this , just add a breakpoint on whatever function you are executing (here signUp ig). And check for the value of host
Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting
Recommended threads
- How to use dart workspaces to deploy a f...
Hello, I'm developing a Flutter application and I would like to leverage dart pub workspaces to deploy a function with a dart runtime as advertised here : http...
- Issue Related to Presence
```PresenceService: upsert error – AppwriteException: user_unauthorized, The current user is not authorized to perform the requested action. (401) ...
- iOS Auth - Apple OAuth not working.
when i use the prod app, the apple auth on ios is not working, it shows me: missing redirect url. however the debug version, connected to another project is wor...