Skip to main content
Partner preview Your iOS app can present an access request to 1Password without sending the person to another app. You pass 1Password the access request reference you got when you created the request. 1Password shows the person a sheet that names your app and what it asked for, and they decide whether to grant it. Your app then gets back either the access grant or an error. Your app talks to 1Password through its action extension. You present the request in the system share sheet, UIActivityViewController, and the person picks 1Password.
The action extension is available in 1Password for iOS 8.12.42 or later. See Supported builds.

How it works

  1. Your app wraps the access request reference in an OnePasswordAccessRequest, encodes it as JSON, and attaches it to an NSExtensionItem as com.1password.access-request.
  2. Your app presents a UIActivityViewController with that item, and the person picks 1Password.
  3. 1Password shows the access request, unlocking first if needed, and the person grants or declines it.
  4. Your app’s completionWithItemsHandler receives either a com.1password.access-grant attachment, which decodes to an OnePasswordAccessGrant, or an error.
The grant comes back to your app directly, so you don’t have to poll for the decision.

Get the access request reference

Create the access request first. The reference is the value 1Password reads to find the account and the request, including what you asked for and why. It’s the access_request_reference value in the appLink returned when you create the request, by the browser extension’s createAccessRequest or by the SDK’s accessRequests.create. If you create requests with the SDK, contact 1Password first. Pass the reference unchanged. Don’t decode it, edit it, or build it from parts. Like the approval link, it carries your request text, so keep it out of logs and model context.

Add the integration types

1Password provides these Swift definitions. Add them to your app target:

The request

The access grant

The access grant is the access request’s status, read from 1Password after the person granted it. It matches what the SDK’s accessRequests.getStatus returns, except for reference: in the grant, each reference is an object that wraps the reference string, { "reference": "<string>" }, while getStatus returns the string itself:
A later version of this protocol is expected to return each reference as a plain string, the same as getStatus.

Declare the 1Password types

Access requests and grants use two Uniform Type Identifiers. Both conform to public.json. 1Password owns these types, so declare them as imported types in your app’s Info.plist:
Info.plist
The integration types refer to these identifiers with UTType(importedAs:), which resolves them correctly only once your Info.plist declares them.

Send the access request

  1. Wrap the access request reference in an OnePasswordAccessRequest and encode it as JSON.
  2. Register the JSON on an NSItemProvider, then attach the provider to an NSExtensionItem.
  3. Create a UIActivityViewController with that item, and present it the way your app presents any share sheet.
If 1Password doesn’t appear in the share sheet, the person can turn it on under More in the row of actions.

Handle the result

UIKit calls completionWithItemsHandler when the share sheet closes. What you receive depends on how the request ended:

Decode the access grant

Find the attachment that conforms to the access grant type, load its JSON, and decode it as an OnePasswordAccessGrant:

Use the grant

Each reference in the grant identifies one granted login. It holds no secret, and it works only with the access token and integration key of the connection that created the request, which stay on your side. The extension and the SDK both take the string inside it, reference.reference, not the object:
  • To fill in your agent’s browser: pass reference.reference to the extension’s fillCredential as resourcePath, with the same connection’s access token and integration key.
  • To read the login with the SDK: pass reference.reference to the SDK’s read methods. See Read a granted login.

Errors

If the person declines, or 1Password can’t process the request, the share sheet passes you an error. These are the errors 1Password reports today, the cases of OnePasswordAccessRequestError: Treat any other error as a failed access request. 1Password may add error cases, and the system can pass you errors of its own.