Hi, I'm using Google OAuth and Appwrite 1.4.1 and before with 1.3.8 I never got this error: Invalid success param: URL host must be one of: localhost, backend.justitis.it
Can you show your code?
import 'dart:convert';
import 'package:appwrite/models.dart';
import 'package:flutter/material.dart';
import 'package:justitis_app/services/appwrite_service.dart';
enum AuthStatus{
uninit, auth, unauth
}
class AuthProvider extends ChangeNotifier{
late User _currentUser;
double _wallet = 0.0;
double _moneyToAdd = 0.0;
AuthStatus _authStatus = AuthStatus.uninit;
// Getter
User get currentUser => _currentUser;
AuthStatus get authStatus => _authStatus;
double get wallet => _wallet;
double get moneyToAdd => _moneyToAdd;
set moneyToAdd(double money) => _moneyToAdd = money;
// Remote Server (deprecated)
// final String userCollectionId = '64d295100d412a890d19';
// final String _successRedirectUrl = 'https://test.justitis.it/auth.html';
//Local Server
final String _userCollectionId = 'users';
final String _successRedirectUrl = 'http://test.justitis.it/auth.html';
AuthProvider(){
checkIfLogged();
}
void checkIfLogged() async{
try{
_currentUser = await AppwriteService.account.get();
_authStatus = AuthStatus.auth;
updateWallet();
}catch(e){
_authStatus = AuthStatus.unauth;
}finally{
notifyListeners();
}
}
void updateWallet() async{
try{
var result = await AppwriteService.database.getDocument(databaseId: AppwriteService.databaseId, collectionId: _userCollectionId, documentId: _currentUser.$id);
var document = result.toMap();
_wallet = (document['data']['balance'] + 0.0);
}finally{
notifyListeners();
}
}
void logIn() async{
try{
//final session =
await AppwriteService.account.createOAuth2Session(provider: 'google', success: _successRedirectUrl);
_currentUser = await AppwriteService.account.get();
_authStatus = AuthStatus.auth;
updateWallet();
}finally{
notifyListeners();
}
}
I think it’s because you didn’t provide a failure url.
Either have both success and failure, or none
ok, i'll try
nope, same error
Both ways? Removing the success and failure params gave same error?
This is what I meant
void logIn() async{
try{
//final session =
await AppwriteService.account.createOAuth2Session(provider: 'google');
_currentUser = await AppwriteService.account.get();
_authStatus = AuthStatus.auth;
updateWallet();
}finally{
notifyListeners();
}
}
now started working
thank you!
[SOLVED] Invalid success param
Success and failure URL must be a subdomain of your Appwrite instance AND added as a Web platform.
I think that might be why
Recommended threads
- Appwrite-injected variables are not avai...
I am using rust-1.83 as a runtime and try to access APPWRITE_FUNCTION_API_ENDPOINT or APPWRITE_FUNCTION_API_KEY during runtime. Both are not set during my execu...
- Appwrite (Dart SDK) (for package_info_pl...
Hi team! Many Flutter plugins now need package_info_plus 10.x and device_info_plus 13.x, but appwrite 25.4.0 still constrains package_info_plus: >=8.0.2 <10.0...
- OAuth Missing redirect URL
Hello all, on a Flutter mobile app with latest Appwrite dependency (25.4.0) I always got "Missing redirect URL" - "Your OAuth login flow is missing a proper red...