For iOS with AppAuth SDK

This quickstart guide serves as an integration example for our trusted partners so that you will be able to test and/or evaluate LoginID’s authentication service for your own needs.

Create your client API Keys

To obtain our client API keys among with other credentials you will need for our AppAuth SDK, please contact

Install AppAuth SDK for your Build Environment

To configure your Xcode environment using Cocoapods please follow instructions on AppAuth SDK GitHub here.

This integration required Safari FIDO2 WebAuthn available on iOS 14.

Add AppAuth to your Podfile and then Run pod install.

target 'MyTestOauthApp' do
#LoginSDK pod install
pod AppAuth
# your other pods

Setup a Custom URL scheme in Info.plist

The custom URI scheme = lid-[unique-id] part of your callbackURL

Setup Oauth2 Redirect Handler in AppDelegate's openUrl Method

import AppAuth
class AppDelegate: UIResponder, UIApplicationDelegate {
// initialize OIDC Authorization Session
var currentAuthorizationFlow: OIDExternalUserAgentSession?
// handle oauth2 custom uri scheme redirect here
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if let authorizationFlow = self.currentAuthorizationFlow,
authorizationFlow.resumeExternalUserAgentFlow(with: url) {
self.currentAuthorizationFlow = nil
return true
// Your additional URL handling (if any)
return false

Setup Oauth2 Authorization Request in the Login View Controller

Import AppAuth

import AppAuth

Configure OIDC Service Endpoints

// configure authorization endpoint
let authorizationEndpoint = URL(string: "")!
// configure token endpoint
let tokenEndpoint = URL(string: "")!
let configuration = OIDServiceConfiguration
(authorizationEndpoint:authorizationEndpoint, tokenEndpoint: tokenEndpoint)

Configure Authorization Request and Handle Authorization

let clientID = ""
let clientSecret = ""
let redirectURI = URL(string:"://oauth2redirect")!
let request = OIDAuthorizationRequest(configuration: configuration,
clientId: clientID,
clientSecret: clientSecret,
scopes: [OIDScopeOpenID],
redirectURL: redirectURI,
responseType: OIDResponseTypeCode,
additionalParameters: nil)
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.currentAuthorizationFlow =
OIDAuthState.authState(byPresenting: request, presenting: self) { authState, error in
if let authState = authState {
// handle success authorization here
print("Authorization success. Access token: " +
"\(authState.lastTokenResponse?.accessToken ?? "nil")")
} else {
// handle authorization error here
print("Authorization error: \(error?.localizedDescription ?? "Unknown error")")