Search code examples
ioscouchbase-litecouchbase-sync-gateway

Couchbase openIDConnect Authentication ios


I am trying to use couchbase DB and set up authentication for it using Authorization Code flow. I followed the steps in this link. I prepared ConfigJson accordingly. Using Pods i installed Couchbase lite for ios and gave the authenticator in following way:

let url = URL.init(string: "http://my-ip:4984/project_name/_oidc")!
pusher = database.createPushReplication(url)
pusher.continuous = true
let authenticator = CBLAuthenticator.openIDConnect({(loginURL: URL, redirectURL: URL, Nonnull: CBLOIDCLoginContinuation) -> Void in

                    print(loginURL,redirectURL)
                })
                pusher.authenticator = authenticator
                pusher.start()

But when I Checked it in terminal "http://my-ip:4984/project_name/_oidc/_session" is hit instead and I am not receiving any callback to the mobile. What am i doing wrong? Sorry I am just a beginner. Why is _session added at the end?


Solution

  • You need to set URL of Your database instead of setting _oidc endpoint. Authentification steps are taken care of by Couchbase Lite's Open ID Connect authenticator.

    So, You need to use let url = URL.init(string: "http://my-ip:4984/project_name/")!