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
configThe 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.paris set totrue, this method will fall back to the standard authorization flow and emit all parameters in the URL query string. To use PAR, call theasyncoverloadgenerateAuthorizeUrl(customParams:) async throws -> URLinstead.Throws
OidcError.networkErrorif the HTTP client or URL cannot be resolved.Declaration
Swift
public func generateAuthorizeUrl(customParams: [String : String]? = nil) throws -> URLParameters
customParamsCustom parameters to include in the authorization request.
Return Value
The fully-built authorization URL.
-
generateAuthorizeUrl(customParams:Asynchronous) 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 -> URLParameters
customParamsCustom parameters to include in the authorization request.
-
extractCodeAndGetToken(from:Asynchronous) Extracts the code from the URL and exchanges it for an access token.
Declaration
Swift
public func extractCodeAndGetToken(from url: URL) async throws -> TokenParameters
urlThe URL to extract the code from.
-
Extract the Redirect URI scheme from the configuration
Declaration
Swift
public func redirectURIScheme() -> String? -
token()AsynchronousRetrieves 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.
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 -> TokenParameters
refreshTokenThe refresh token to use for refreshing the access token.
Return Value
The refreshed access token.
-
revoke()AsynchronousRevokes the access token.
Declaration
Swift
public func revoke() async -
endSession()AsynchronousEnds the session. Best effort to end the session. The stored token is removed regardless of the result.
Declaration
Swift
@discardableResult public func endSession() async -> BoolReturn 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 -> BoolParameters
signOffA suspend function to perform the sign-off.
Return Value
A boolean indicating whether the session was ended successfully.
-
userinfo()Asynchronous -
Represents various constants used in OIDC requests
See moreDeclaration
Swift
public enum Constants
View on GitHub