Back

[SOLVED] Invalid `success` param

  • 0
  • Self Hosted
  • Flutter
  • Accounts
thet3o
1 Sep, 2023, 09:22

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

TL;DR
The user was getting an "Invalid `success` param" error when using Google OAuth with Appwrite 1.4.1. They mentioned that they didn't get this error with Appwrite 1.3.8. They tried removing the success and failure params but still got the same error. Another user suggested that the success and failure URL must be a subdomain of the Appwrite instance, and the user confirmed that adding the correct URL solved the issue for them.
safwan
1 Sep, 2023, 10:39

Can you show your code?

thet3o
1 Sep, 2023, 10:45
TypeScript
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();
    }
  }
safwan
1 Sep, 2023, 11:15

I think it’s because you didn’t provide a failure url.

safwan
1 Sep, 2023, 11:16

Either have both success and failure, or none

thet3o
1 Sep, 2023, 12:04

ok, i'll try

thet3o
1 Sep, 2023, 12:06

nope, same error

safwan
1 Sep, 2023, 12:13

Both ways? Removing the success and failure params gave same error?

safwan
1 Sep, 2023, 12:14

This is what I meant

TypeScript
void logIn() async{
    try{
      //final session = 
      await AppwriteService.account.createOAuth2Session(provider: 'google');
      _currentUser = await AppwriteService.account.get();
      _authStatus = AuthStatus.auth;
      updateWallet();
    }finally{
      notifyListeners();
    }
  }
thet3o
1 Sep, 2023, 12:27

now started working

thet3o
1 Sep, 2023, 12:27

thank you!

Drake
1 Sep, 2023, 15:22

[SOLVED] Invalid success param

VincentGe
1 Sep, 2023, 22:20

Success and failure URL must be a subdomain of your Appwrite instance AND added as a Web platform.

VincentGe
1 Sep, 2023, 22:21

I think that might be why

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more