User

public class User : UserProtocol
extension User: Equatable

Representation of logged-in user.

  • Sets the tokens. Should only be used when testing.

    Declaration

    Swift

    public func setTokens(_ tokens: UserTokens)
  • Delegates listening to User events such as logout

    Declaration

    Swift

    public let delegates: MulticastDelegate
  • user idToken

    Declaration

    Swift

    public var idToken: String? { get }
  • User UUID

    Declaration

    Swift

    public var uuid: String? { get }
  • User integer id (as string). Equivalent of legacyID in old AccountSDK

    A user_id used by some Schibsted account APIs

    Declaration

    Swift

    public var userId: String? { get }
  • Log user out

    Will remove stored session, including all user tokens.

    Declaration

    Swift

    public func logout()
  • Check if this user is logged-in.

    The user may have been logged out either explicitly via logout method or automatically if no valid tokens could be obtained (e.g. due to expired or invalidated refresh token).

    Declaration

    Swift

    public func isLoggedIn() -> Bool
  • Generate URL with embedded one-time code for creating a web session for the current user.

    Declaration

    Swift

    public func webSessionURL(clientId: String,
                              redirectURI: String,
                              state: String? = nil,
                              completion: @escaping HTTPResultHandler<URL>)

    Parameters

    clientId

    which client to get the code on behalf of, e.g. client id for associated web application. Needs to be from the same merchant.

    redirectURI

    where to redirect the user after the session has been created. The exact redirect URI must be registered for the given client in Self Service.

    state

    An opaque value used by the client to maintain state between

    completion

    The callback that receives the URL or an error in case of failure

  • Requests a OAuth authorization code for the current user. The code is short-lived and one-time use only.

    Declaration

    Swift

    public func oneTimeCode(clientId: String, completion: @escaping HTTPResultHandler<String>)

    Parameters

    clientId

    which client to get the code on behalf of, e.g. client id for associated web application

    completion

    callback that receives the one time code

  • Fetch user profile data

    Declaration

    Swift

    public func fetchProfileData(completion: @escaping HTTPResultHandler<UserProfileResponse>)
  • Declaration

    Swift

    public static func == (lhs: User, rhs: User) -> Bool