<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/AuthorizationCopyRights(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@AuthorizationCopyRights"
  },
  "title" : "AuthorizationCopyRights(_:_:_:_:_:)"
}
-->

# AuthorizationCopyRights(_:_:_:_:_:)

Authorizes and preauthorizes rights synchronously.

```
func AuthorizationCopyRights(_ authorization: AuthorizationRef, _ rights: UnsafePointer<AuthorizationRights>, _ environment: UnsafePointer<AuthorizationEnvironment>?, _ flags: AuthorizationFlags, _ authorizedRights: UnsafeMutablePointer<UnsafeMutablePointer<AuthorizationRights>?>?) -> OSStatus
```

## Parameters

`authorization`

An authorization reference referring to the authorization session.

`rights`

A pointer to a set of authorization rights you create. Pass `nil` if the application requires no rights at this time.

`environment`

Data used when authorizing or preauthorizing rights. Not used in OS X v10.2 and earlier. In macOS 10.3 and later, you can pass icon or prompt data to be used in the authentication dialog box. In macOS 10.4 and later, you can also pass a user name and password in order to authorize a user without displaying the authentication dialog box. Possible values for this parameter are listed in `Security.framework/Headers/AuthorizationTags.h`. The data passed in this parameter is not stored in the authorization reference; it is used only during authorization. If you are not passing any data in this parameter, pass the constant [`kAuthorizationEmptyEnvironment`](/documentation/Security/kAuthorizationEmptyEnvironment).

`flags`

A bit mask for specifying authorization options. Use the following option sets.

- Pass the constant [`kAuthorizationFlagDefaults`](/documentation/Security/AuthorizationFlags/kAuthorizationFlagDefaults) if no options are necessary.
- Specify the [`extendRights`](/documentation/Security/AuthorizationFlags/extendRights) mask to request rights. You can also specify the [`interactionAllowed`](/documentation/Security/AuthorizationFlags/interactionAllowed) mask to allow user interaction.
- Specify the [`partialRights`](/documentation/Security/AuthorizationFlags/partialRights) and [`extendRights`](/documentation/Security/AuthorizationFlags/extendRights) masks to request partial rights. You can also specify the [`interactionAllowed`](/documentation/Security/AuthorizationFlags/interactionAllowed) mask to allow user interaction.
- Specify the [`preAuthorize`](/documentation/Security/AuthorizationFlags/preAuthorize) and [`extendRights`](/documentation/Security/AuthorizationFlags/extendRights) masks to preauthorize rights.
- Specify the [`destroyRights`](/documentation/Security/AuthorizationFlags/destroyRights) mask to prevent the Security Server from preserving the rights obtained during this call.

`authorizedRights`

A pointer to a newly allocated [`AuthorizationRights`](/documentation/Security/AuthorizationRights) structure. On return, this structure contains the rights granted by the Security framework. If you do not require this information, pass `nil`. If you specify the [`preAuthorize`](/documentation/Security/AuthorizationFlags/preAuthorize) mask in the `flags` parameter, the method returns all the requested rights, including those not granted, but the flags of the rights that could not be preauthorized include the [`kAuthorizationFlagCanNotPreAuthorize`](/documentation/Security/kAuthorizationFlagCanNotPreAuthorize) bit.
Free the memory associated with this set by calling the function [`AuthorizationFreeItemSet(_:)`](/documentation/Security/AuthorizationFreeItemSet(_:)).

## Return Value

A result code. See [Authorization Services Result Codes](/documentation/Security/authorization-services-result-codes).

## Discussion

There are three main reasons to use this function. The first reason is to preauthorize rights by specifying the [`preAuthorize`](/documentation/Security/AuthorizationFlags/preAuthorize), [`interactionAllowed`](/documentation/Security/AuthorizationFlags/interactionAllowed), and [`extendRights`](/documentation/Security/AuthorizationFlags/extendRights) masks as authorization options. Preauthorization is most useful when a right has a zero timeout. For example, you can preauthorize in the application and if it succeeds, call the helper tool and request authorization. This eliminates calling the helper tool if the Security Server cannot later authorize the specified rights.

The second reason to use this function is to authorize rights before performing a privileged operation by specifying the [`interactionAllowed`](/documentation/Security/AuthorizationFlags/interactionAllowed), and [`extendRights`](/documentation/Security/AuthorizationFlags/extendRights) masks as authorization options.

The third reason to use this function is to authorize partial rights. By specifying the [`partialRights`](/documentation/Security/AuthorizationFlags/partialRights), [`interactionAllowed`](/documentation/Security/AuthorizationFlags/interactionAllowed), and [`extendRights`](/documentation/Security/AuthorizationFlags/extendRights) masks as authorization options, the Security Server grants all rights it can authorize. On return, the authorized set contains all the rights.

If you do not specify the [`partialRights`](/documentation/Security/AuthorizationFlags/partialRights) mask and the Security Server denies at least one right, then the status of this function on return is [`errAuthorizationDenied`](/documentation/Security/errAuthorizationDenied).

If you do not specify the [`interactionAllowed`](/documentation/Security/AuthorizationFlags/interactionAllowed) mask and the Security Server requires user interaction, then the status of this function on return is [`errAuthorizationInteractionNotAllowed`](/documentation/Security/errAuthorizationInteractionNotAllowed).

If you specify the [`interactionAllowed`](/documentation/Security/AuthorizationFlags/interactionAllowed) mask and the user cancels the authentication process, then the status of this function on return is [`errAuthorizationCanceled`](/documentation/Security/errAuthorizationCanceled).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)