Shared Web Credentials

Share credentials between iOS apps and their website counterparts.

Overview

The Security.SecSharedCredentials API provides functions for storing and requesting shared password-based credentials. Users often save their username and password in their iCloud keychain when logging into websites in Safari. Later, they may run a native app from the same developer to access the same account. With shared web credentials, the app can access the credentials stored for the website instead of requiring the user to reenter a username and password. Users can also create new accounts, update passwords, or delete their accounts from within the app. These changes are then saved and used by Safari.

Figure 1

Using shared web credentials API and the iCloud keychain to bridge between your app and your website

Diagram showing a connection between your app and Safari through iCloud keychain.

Topics

First Steps

Preparing Your App and Website to Share

Add an entitlement to your app and a file to your website to enable sharing.

Managing Shared Credentials

Use shared web credentials to create a seamless experience for the user.

Password Sharing

func SecAddSharedWebCredential(CFString, CFString, CFString?, (CFError?) -> Void)

Asynchronously stores (or updates) a shared password for a website.

func SecRequestSharedWebCredential(CFString?, CFString?, (CFArray?, CFError?) -> Void)

Asynchronously obtains one or more shared passwords for a website.

func SecCreateSharedWebCredentialPassword()

Returns a randomly generated password.

let kSecSharedPassword: CFString

A dictionary key whose value is the shared password.

See Also

Authorization and Authentication

Authorization Services

Access restricted areas of the operating system, and control access to particular features of your macOS app.

Authorization Plug-ins

Extend the authorization services API by creating plug-ins that can participate in authorization decisions.

Sessions

Manage login, authorization, and security sessions in macOS.