---
title: SecKeyGetCredentials
framework: security
role: symbol
role_heading: Function
path: security/seckeygetcredentials
---

# SecKeyGetCredentials

Returns an access credential for a key.

## Declaration

```occ
OSStatus SecKeyGetCredentials(SecKeyRef keyRef, CSSM_ACL_AUTHORIZATION_TAG operation, SecCredentialType credentialType, const CSSM_ACCESS_CREDENTIALS **outCredentials);
```

## Parameters

- `keyRef`: The key for which you want an access credential.
- `operation`: The type of operation to be performed with this key. Possible values are listed under “Authorization tag types” in Security.framework/cssmtype.h.
- `credentialType`: The type of credential requested. See doc://com.apple.security/documentation/Security/SecCredentialType for possible values.
- `outCredentials`: On return, points to an access credential for the specified key. This pointer remains valid until the key reference is released. Do not attempt to modify or free this data.

## Return Value

Return Value A result code. See Security Framework Result Codes.

## Discussion

Discussion An access credential is required as an input to a number of CSSM functions.
