<!--
{
  "availability" : [
    "macOS: 10.14.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWorkspace/requestAuthorization(to:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWorkspace(im)requestAuthorizationOfType:completionHandler:"
  },
  "title" : "requestAuthorization(to:completionHandler:)"
}
-->

# requestAuthorization(to:completionHandler:)

Requests authorization to perform a privileged file operation.

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

## 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:

- authorization: The authorization granted for this app. Use it when creating a new <doc://com.apple.documentation/documentation/Foundation/FileManager> with <doc://com.apple.documentation/documentation/Foundation/FileManager/init(authorization:)>.
- error: `nil` if the app is authorized; otherwise, a pointer to the authorization error.

## Discussion

---

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)