OidcClient

public class OidcClient

Class representing an OpenID Connect client.

  • Property pkce: PKCE object used for the Authorization call.
  • Declaration

    Swift

    public var pkce: Pkce?
  • OidcClient initializer.

    Declaration

    Swift

    public init(config: OidcClientConfig)

    Parameters

    config

    The configuration for this client.

  • Generates an OIDC authorization URL synchronously.

    Warning

    This synchronous variant does not support Pushed Authorization Requests (PAR, RFC 9126). Even when OidcClientConfig.par is set to true, this method will fall back to the standard authorization flow and emit all parameters in the URL query string. To use PAR, call the async overload generateAuthorizeUrl(customParams:) async throws -> URL instead.

    Throws

    OidcError.networkError if the HTTP client or URL cannot be resolved.

    Declaration

    Swift

    public func generateAuthorizeUrl(customParams: [String : String]? = nil) throws -> URL

    Parameters

    customParams

    Custom parameters to include in the authorization request.

    Return Value

    The fully-built authorization URL.

  • OidcClient generateAuthorizeUrl with PAR support. When PAR is enabled in the configuration, authorization parameters are pushed to the server before generating the URL.

    Declaration

    Swift

    public func generateAuthorizeUrl(customParams: [String : String]? = nil) async throws -> URL

    Parameters

    customParams

    Custom parameters to include in the authorization request.

  • Extracts the code from the URL and exchanges it for an access token.

    Declaration

    Swift

    public func extractCodeAndGetToken(from url: URL) async throws -> Token

    Parameters

    url

    The URL to extract the code from.

  • Extract the Redirect URI scheme from the configuration

    Declaration

    Swift

    public func redirectURIScheme() -> String?
  • token() Asynchronous

    Retrieves an access token. If a cached token is available and not expired, it is returned. Otherwise, a new token is fetched with refresh token if refresh grant is available.

    Declaration

    Swift

    public func token() async -> Result<Token, OidcError>

    Return Value

    A Result containing the access token or an error.

  • refreshToken(_:) Asynchronous

    Refreshes the access token.

    Declaration

    Swift

    public func refreshToken(_ refreshToken: String) async throws -> Token

    Parameters

    refreshToken

    The refresh token to use for refreshing the access token.

    Return Value

    The refreshed access token.

  • revoke() Asynchronous

    Revokes the access token.

    Declaration

    Swift

    public func revoke() async
  • endSession() Asynchronous

    Ends the session. Best effort to end the session. The stored token is removed regardless of the result.

    Declaration

    Swift

    @discardableResult
    public func endSession() async -> Bool

    Return Value

    A boolean indicating whether the session was ended successfully.

  • endSession(signOff:) Asynchronous

    Ends the session with a custom sign-off procedure.

    Declaration

    Swift

    @discardableResult
    public func endSession(signOff: @escaping (String) async throws -> Bool) async -> Bool

    Parameters

    signOff

    A suspend function to perform the sign-off.

    Return Value

    A boolean indicating whether the session was ended successfully.

  • userinfo() Asynchronous

    Retrieves user information.

    Declaration

    Swift

    public func userinfo() async -> Result<UserInfo, OidcError>

    Return Value

    A Result containing the user information or an error.

  • Represents various constants used in OIDC requests

    See more

    Declaration

    Swift

    public enum Constants