---
title: "requestAuthorization(_:)"
framework: mediaplayer
role: symbol
role_heading: Type Method
path: "mediaplayer/mpmedialibrary/requestauthorization(_:)"
---

# requestAuthorization(_:)

Displays a user interface so that the user can authorize whether your app may view the media library’s contents.

## Declaration

```swift
class func requestAuthorization(_ completionHandler: @escaping @Sendable (MPMediaLibraryAuthorizationStatus) -> Void)
```

```swift
class func requestAuthorization() async -> MPMediaLibraryAuthorizationStatus
```

## Parameters

- `completionHandler`: A block that the system calls after the user chooses whether to authorize the app.

## See Also

### Getting the default media library

- [authorizationStatus()](mediaplayer/mpmedialibrary/authorizationstatus().md)
- [MPMediaLibraryAuthorizationStatus](mediaplayer/mpmedialibraryauthorizationstatus.md)
- [default()](mediaplayer/mpmedialibrary/default().md)
