<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/AuthorizationCallbacks/GetContextValue",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@S@AuthorizationCallbacks@FI@GetContextValue"
  },
  "title" : "GetContextValue"
}
-->

# GetContextValue

Reads a value collected during authorization.

```
int (*)(struct __OpaqueAuthorizationEngine *, const char *, enum AuthorizationContextFlags *, const struct AuthorizationValue **) GetContextValue;
```

## Parameters

`inEngine`

An opaque handle that is passed to your plug-in when the authorization engine calls your [`MechanismCreate`](/documentation/Security/AuthorizationPluginInterface/MechanismCreate) function.

`inKey`

A key indicating which value you want to retrieve. This key must correspond to one you specified when you used the [`SetContextValue`](/documentation/Security/AuthorizationCallbacks/SetContextValue) function to store a context value.

`outContextFlags`

On output points to a flag that indicates whether this value is available to the authorization client.

`outValue`

On input, allocate a pointer to an [`AuthorizationValue`](/documentation/Security/AuthorizationValue) structure. On output, the structure contains the size of the data and a pointer to the data. Because your [`AuthorizationValue`](/documentation/Security/AuthorizationValue) structure does not own the data, you must not deallocate the structure or the data pointed to by the structure.

## Return Value

A result code. Possible results are [`errAuthorizationSuccess`](/documentation/Security/errAuthorizationSuccess) (no error) and [`errAuthorizationInternal`](/documentation/Security/errAuthorizationInternal) (Security Server internal error).

## Discussion

Your plug-in authorization mechanism might collect data such as the user name and other authentication information during evaluation of authorization. You can use the [`SetContextValue`](/documentation/Security/AuthorizationCallbacks/SetContextValue) function to have the Security Server store this data and the [`GetContextValue`](/documentation/Security/AuthorizationCallbacks/GetContextValue) function to retrieve it.

The authorization engine sends you the entry point to the [`GetContextValue`](/documentation/Security/AuthorizationCallbacks/GetContextValue) function in an [`AuthorizationCallbacks`](/documentation/Security/AuthorizationCallbacks) structure when you call the [`AuthorizationPluginCreate`](/documentation/Security/AuthorizationPluginCreate) function.

> Important:
> Do not call this function after you have called the ``doc://com.apple.security/documentation/Security/AuthorizationCallbacks/SetResult`` function. If you do so, the data retrieved by the `GetContextValue` function might not reflect the current value even though the function returns the ``doc://com.apple.security/documentation/Security/errAuthorizationSuccess`` result code.

---

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)