iOS—Full OAuth implementation

In the iOS—Full OAuth implementation, the SDK handles the entire OAuth process, requiring your app to establish only the necessary connections between the SDK and iOS. Use Full OAuth when you want the SDK to manage the entire OAuth flow. This implementation simplifies token management but requires handling URL redirections and lacks customization for the login experience.

Pros:

  • Automatic token management—The SDK manages refresh tokens, ensuring you always have a valid token.
  • External browser handling—The SDK redirects to an external browser for the Clover login page.

Cons:

  • URL monitoring—You need to monitor incoming URLs in your Scene Delegate and pass them to the SDK. After a successful login, the URL contains the code needed to obtain the auth token.
  • No screen branding—You cannot customize the login screen.
  • App exit—The app exits to the default browser for login and then returns using the redirect URL and your applinks definition.

Before you begin

Steps

  1. Add a token change callback using theCloverPaymentSDK.shared.addOnTokenChangeCallback.
  2. Initialize the SDK by calling CloverPaymentSDK.shared.setup and passing in your configuration object. Include a CloverPaymentSDK.FullOAuth object in the configuration for full OAuth support.
  3. CloverPaymentSDK attempts to recover a valid token stored securely in the Keychain.
    1. If a valid token is found, it completes initialization and calls your success callback registered in step 2.
    2. If no valid token is found, CloverPaymentSDK initiates OAuth login using the device's default browser. A login page displays for the user in your configured environment. User information passes from your configuration to ensure your app can log in for the merchant and employee.
  4. Upon successful login, a code is provided by a callback to your registered associated domain. This returns to your app using the Scene delegate or another appropriate path. See the Apple documentation for options.
  5. Pass the full URL containing the code back to your handler using CloverPaymentSDK.shared.receivedOAuthCodeOrToken.
  6. CloverPaymentSDK exchanges the code for a token stores the token in the Keychain for the next launch and then calls your token change callback registered in step 1.
  7. In your callback, call CloverPaymentSDK.shared.setup to retry initialization with the valid token.
iOS - Full OAuth flow

iOS—Full OAuth flow


Related topics