iOS: "Could not validate redirect, please whitelist your domain" after whitelisting and correct network

I have correctly whitelisted my domain as instructed, I have properly configured on the app the network to be sapphire_devnet and my own client ID, same as on the dashboard but still get this error. I am simply trying to use the given iOS example code locally to try out the SDK. I have seen similar posts and followed the solutions, but haven’t been able to fix this. I have tried creating new projects on testnet instead and still get to the same issue. I am still new to the SDK and iOS, any help would be appreciated.

My code, taken from the example code on GitHub:

import Foundation

import Web3Auth

class ViewModel: ObservableObject {
    var web3Auth: Web3Auth?
    @Published var loggedIn: Bool = false
    @Published var user: Web3AuthState?
    @Published var isLoading = false
    @Published var navigationTitle: String = ""
    private var clientId = "BP9CvuBjgOrYv-E3soGrZFQfyR7nwMqxvPJrdsR8qD2e5ypW_nlOW-KIaaiqkjJmIQbrihtHMMO2ViBvHsIO0pot"
    private var network: Network = .sapphire_devnet
    func setup() async {
        guard web3Auth == nil else { return }
        await MainActor.run(body: {
            isLoading = true
            navigationTitle = "Loading"
        })
        
        web3Auth = await Web3Auth(W3AInitParams(
            clientId: clientId, network: network
        ))
        
        
        await MainActor.run(body: {
            if self.web3Auth?.state != nil {
                user = web3Auth?.state
                loggedIn = true
            }
            isLoading = false
            navigationTitle = loggedIn ? "UserInfo" : "SignIn"
        })
    }
    
    func login(provider: Web3AuthProvider) {
        Task {
            do {
                let result = try await web3Auth?.login(
                    W3ALoginParams(loginProvider: provider)
                )
                await MainActor.run(body: {
                    user = result
                    loggedIn = true
                })
                
            } catch {
                print("Error")
            }
        }
    }

Hey @marius,

Welcome to using the Web3Auth SDK! We’re here to support you every step of the way. It looks like you’ve correctly set up the Web3Auth network and the client ID matches between your dashboard and the app, which is great.

There seems to be a small oversight in the URL you’ve whitelisted. You’ve listed com.test-app.cyb:auth but it should actually be com.test-app.cyb://auth. Making this minor change should resolve the issue if there are no other complications.

Happy developing with Web3Auth, and thank you for turning to our community with your questions!

Hey @maharshi,
Really appreciate the reply. I’ve actually exactly put it in the format you’ve mentioned. It displays my text input of com.test-app.cyb://auth as com.test-appp.cyb:auth on the dashboard after entering it. Seems the forward slashes disappears. Attempting to input com.test-appp.cyb://auth again tells me it has already been whitelisted. Deleting and entering again has not worked either. Wondering if I am still missing something in the setup? Also wondering why this whitelisting is needed and why this error would show when I am simply running in an Xcode project locally (on my mobile device)

Worked after trying in Chrome instead of safari!

1 Like