---
title: "credentials(for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlcredentialstorage/credentials(for:)"
---

# credentials(for:)

Returns a dictionary containing the credentials for the specified protection space.

## Declaration

```swift
func credentials(for space: URLProtectionSpace) -> [String : URLCredential]?
```

## Parameters

- `space`: The protection space whose credentials you want to retrieve.

## Return Value

Return Value A dictionary containing the credentials for the specified protection space. The dictionary’s keys are user name strings, and each value is the corresponding URLCredential.

## Discussion

Discussion If you override this method, also override getCredentials(for:task:completionHandler:).

## See Also

### Retrieving credentials

- [allCredentials](foundation/urlcredentialstorage/allcredentials.md)
- [getCredentials(for:task:completionHandler:)](foundation/urlcredentialstorage/getcredentials(for:task:completionhandler:).md)
