Skip to content

Abstract customer accounts api to ShopifyCustomerAccounts - #512

Draft
markmur wants to merge 1 commit into
android-customer-accounts-auth-tabfrom
abstract-customer-accounts
Draft

Abstract customer accounts api to ShopifyCustomerAccounts#512
markmur wants to merge 1 commit into
android-customer-accounts-auth-tabfrom
abstract-customer-accounts

Conversation

@markmur

@markmur markmur commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Consumer API

import ShopifyCustomerAccounts
import UIKit

@MainActor
final class AccountService {
    private let client: CustomerAccountClient

    init() {
        let configuration = CustomerAccountConfiguration(
            shopID: "<shop-id>",
            clientID: "<customer-account-client-id>",
            redirectURI: URL(string: "myapp://customer-account/callback")!
            // browserSession defaults to .shared
        )

        client = CustomerAccountClient(configuration: configuration)
    }

    /// Call during app startup.
    func restoreSession() async {
        try? await client.restoreSession()
    }

    func signIn(from viewController: UIViewController) async throws {
        try await client.signIn(from: viewController)

        // Explicitly connect the account to your Storefront cart.
        let accessToken = try await client.accessToken()
        try await updateCartBuyerIdentity(
            customerAccessToken: accessToken
        )
    }

    func signOut(from viewController: UIViewController) async throws {
        // Performs Shopify's browser-based logout and clears local credentials.
        try await client.signOut(from: viewController)

        // App-owned cleanup remains explicit.
        try await resetCart()
    }

    func clearLocalSession() throws {
        // Clears this app's credentials without browser-based logout.
        try client.clearSession()
    }
}

The app must register the redirect URI's custom scheme (in this example, myapp) under CFBundleURLTypes.

The browser session is shared by default. Consumers can opt into an isolated session with browserSession: .ephemeral.

ShopifyCustomerAccounts owns authentication and token management, while cart integration remains explicit and app-owned.


Before you merge

Important

  • I've added tests to support my implementation
  • I have read and agree with the Contribution Guidelines
  • I have read and agree with the Code of Conduct
  • I've updated the relevant platform README (platforms/swift/README.md and/or platforms/android/README.md)

Releasing a new Swift version?
  • I have bumped the version in ShopifyCheckoutKit.podspec
  • I have bumped the version in platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift
  • I have updated the SwiftPM/CocoaPods version snippets in platforms/swift/README.md (major version only)
Releasing a new Embedded Checkout Protocol version?
  • I have bumped embeddedCheckoutProtocolAndroid in platforms/android/gradle/libs.versions.toml
  • I have updated protocol/languages/kotlin/embedded-checkout-protocol/api/embedded-checkout-protocol.api if the public API changed
Releasing a new Android version?
  • I have bumped checkoutKitAndroid in platforms/android/gradle/libs.versions.toml
  • I have updated the Gradle/Maven version snippets in platforms/android/README.md

Tip

See the Contributing documentation for the full release process per platform.

@github-actions github-actions Bot added the #gsd:50662 Rebase Checkout Kit on UCP label Jul 23, 2026

markmur commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@markmur markmur changed the title Abstract customer accounts api to ShopifyCustomerAccounts # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # HEAD detached at c9738a97 # Changes to be committed: # mod Abstract customer accounts api to ShopifyCustomerAccounts Jul 23, 2026
@markmur
markmur force-pushed the abstract-customer-accounts branch from 90b006f to bc4140c Compare July 23, 2026 18:13
@markmur
markmur force-pushed the migrate-demo-to-aswebauthenticationsession branch from c9738a9 to a1d8d89 Compare July 23, 2026 18:13
@markmur
markmur force-pushed the abstract-customer-accounts branch from a836123 to c1754a8 Compare July 23, 2026 19:50
@markmur
markmur changed the base branch from migrate-demo-to-aswebauthenticationsession to graphite-base/512 July 23, 2026 19:50
@markmur
markmur changed the base branch from graphite-base/512 to android-customer-accounts-auth-tab July 23, 2026 19:50
@markmur markmur self-assigned this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant