github “auth0/Auth0.swift” “1.13.0”
github “auth0/Lock.iOS-OSX” “2.4.0”
I have problems to refresh session and obtain profile
When login with the LOGIN method, the returned Profile don´t have the “real” properties (“emailVerified” returns false when is true)
If use DEPRECATED LOGIN, GET PROFILE with the “accessToken” provide return a “good profile”, but later, when refresh token, make a GET PROFILE with the “new accessToken” return a “bad profile”
- DEPRECATED LOGIN
func login(usernameOrEmail username: String, password: String, multifactorCode: String?, connection: String, scope: String, parameters: [String : Any])
-
LOGIN
func loginWith(user: String, pass: String) { Auth0.authentication() .login(usernameOrEmail: user, password: pass, realm: Auth0Connection.userPass.rawValue, audience: "https://***********", scope: "openid profile offline_access") .start { result in DispatchQueue.main.async { switch result { case .success(let credentials): //- In loginDidFinish SAVE CREDENTIALS self.output?.loginDidFinish(result: .success(result: credentials)) case .failure(let error): self.output?.loginDidFinish(result: .error(error: error)) } } } }
-
GET PROFILE
func authentication(accessToken: String, callback: @escaping (Error?) -> ()) { Auth0.authentication() .userInfo(token: accessToken) .start { result in switch(result) { case .success(let profile): self.output?.authDidFinish(result: .successCallBack(result: profile, callback: callback)) case .failure(let error): LogWarn(error.localizedDescription) self.output?.authDidFinish(result: .errorCallBack(callback: callback)) } } }
-
REFRESH ACCESS TOKEN
Auth0.authentication() .renew(withRefreshToken: refreshToken, scope: "openid profile offline_access") .start { result in switch(result) { case .success(let credentials): //- RETRY GET PROFILE WITH ACCESS TOKEN self.output?.refreshTokenDidFinish(result: .success(result: credentials, callback: callback)) case .failure(let error): self.output?.refreshTokenDidFinish(result: .error(error: error, callback: callback)) } }