Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Realm Object Server Returns Invalid Credentials from iOS App #264

Closed
1 of 3 tasks
doswelleth-zz opened this issue Sep 5, 2017 · 2 comments
Closed
1 of 3 tasks

Realm Object Server Returns Invalid Credentials from iOS App #264

doswelleth-zz opened this issue Sep 5, 2017 · 2 comments

Comments

@doswelleth-zz
Copy link

Goals

Log into Realm Object Server from iOS app

Expected Results

Success

Actual Results

fatal error: Optional(Error Domain=io.realm.sync.auth Code=611 "The provided credentials are invalid or a user does not exist." UserInfo={NSLocalizedDescription=The provided credentials are invalid or a user does not exist.

Steps to Reproduce

`SyncUser.logIn(with: SyncCredentials.usernamePassword(username: username, password: password), server: URL(string: "http://**********:9080")!) { (user, error) in
guard let user = user else {
fatalError(String(describing: error))
}
let permissions = SyncPermissionValue(realmPath: "
", userID: "
", accessLevel: .write)
user.applyPermission(permissions) { error in
if error != nil { return }
}
user.retrievePermissions { permissions, error in
if error != nil { return }
}

        DispatchQueue.main.async {
            let configuration = Realm.Configuration(
                syncConfiguration: SyncConfiguration(user: user, realmURL: URL(string: "realm://************:9080/~/listRealm")!))
           
            let realm = try! Realm(configuration: configuration)
            self.items = realm.objects(Item.self).sorted(byKeyPath: "created", ascending: false)
            self.notificationToken = self.item.addNotificationBlock { [weak self] (changes: RealmCollectionChange) in
                
                guard (self?.collectionView) != nil else { return }
                
                switch changes {
                case .initial:
                    self?.collectionView.reloadData()
                    break
                    
                case .update(_, let deletions, let insertions, let modifications):
                    self?.collectionView.performBatchUpdates({
                        self?.collectionView.insertItems(at: insertions.map({ IndexPath(row: $0, section: 0)}))
                        self?.collectionView.deleteItems(at: deletions.map({ IndexPath(row: $0, section: 0)}))
                        self?.collectionView.reloadItems(at: modifications.map({ IndexPath(row: $0, section: 0)}))
                    }, completion: nil)
                    break
                    
                case .error(let error):
                    print(error.localizedDescription)
                    break
                }
            }
        }
    }`

Version of Realm and Tooling

  • Realm Object Server Version: 2.1.12
  • Flavor:
    • Developer
    • Professional
    • Enterprise
  • Server OS & Version: macOS
  • Client SDK Version: RealmSwift 3.1
  • Client OS & Version: Swift 3.1

Logs

@doswelleth-zz
Copy link
Author

I canConnect to Object Server and Open Realm URL, the latter with a token and with credentials. So I am certain it is something in my code client side. But just in case there was something else I missed... 😀

@doswelleth-zz
Copy link
Author

Setting the register parameter to true fixed the issue. I did not include it in my initial SyncUser.login constructor:

SyncUser.logIn(with: SyncCredentials.usernamePassword(username: username, password: password, **register: true**), server: URL(string: "http://************:9080")!) { (user, error) in }

However, I am able to log in again with the same true credentials without an error. Just a heads up.

Thanks, Austin Z

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant