I am trying to connect my iOS app to a Keycloak server for authentication purposes and have decided to use AeroGear library to do it. I did the initial setup as described in the Readme and configured everything Server side. The code I am using to initiate login is this:
let keycloakConfig = KeycloakConfig(
clientId: "testclient",
host: "http://localhost:8080",
realm: "testrealm",
isOpenIDConnect: true
)
let oauth2Module = AccountManager.addKeycloakAccount(config: keycloakConfig)
//let oauth2Module = KeycloakOAuth2Module(config: keycloakConfig, session: UntrustedMemoryOAuth2Session(accountId: "ACCOUNT_FOR_CLIENTID_\(keycloakConfig.clientId)"))
let http = Http()
http.authzModule = oauth2Module
oauth2Module.login {(accessToken: AnyObject?, claims: OpenIdClaim?, error: NSError?) in
print("login successful")
// some other stuff happens here
}
The app takes me to login screen of Keycloak where I put in the user info and it seems like the login works as I get redirected back to my app. But for some reason nothing that should happen doesn't happen afterwards - for example the print to console. When I tried it in a different app it worked so it must be ok but I don't know how to debug this. The session on Keycloak seems alright so I have no idea what could cause this... I would appreciate some advice as I am very good at this.