---
title: "requestAuthorization(to:completionHandler:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsworkspace/requestauthorization(to:completionhandler:)"
---

# requestAuthorization(to:completionHandler:)

Requests authorization to perform a privileged file operation.

## Declaration

```swift
func requestAuthorization(to type: NSWorkspace.AuthorizationType, completionHandler: @escaping @Sendable (NSWorkspace.Authorization?, (any Error)?) -> Void)
```

```swift
func requestAuthorization(to type: NSWorkspace.AuthorizationType) async throws -> NSWorkspace.Authorization
```

## Parameters

- `type`: The type of file operation to perform.
- `completionHandler`: The completion handler to call when the authorization request is completed. The completion handler takes two parameters:

## Discussion

Discussion

## See Also

### Performing Privileged Operations

- [NSWorkspace.Authorization](appkit/nsworkspace/authorization.md)
- [NSWorkspace.AuthorizationType](appkit/nsworkspace/authorizationtype.md)
