---
title: "requestAuthorization(toShare:read:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkhealthstore/requestauthorization(toshare:read:)"
---

# requestAuthorization(toShare:read:)

Asynchronously requests permission to save and read the specified data types.

## Declaration

```swift
func requestAuthorization(toShare typesToShare: Set<HKSampleType>, read typesToRead: Set<HKObjectType>) async throws
```

## Parameters

- `typesToShare`: A set containing the data types you want to share. This set can contain any concrete subclass of the doc://com.apple.healthkit/documentation/HealthKit/HKSampleType class (any of the doc://com.apple.healthkit/documentation/HealthKit/HKQuantityType, doc://com.apple.healthkit/documentation/HealthKit/HKCategoryType, doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutType, or doc://com.apple.healthkit/documentation/HealthKit/HKCorrelationType classes). If the user grants permission, your app can create and save these data types to the HealthKit store.
- `typesToRead`: A set containing the data types you want to read. This set can contain any concrete subclass of the doc://com.apple.healthkit/documentation/HealthKit/HKObjectType class (any of the doc://com.apple.healthkit/documentation/HealthKit/HKCharacteristicType , doc://com.apple.healthkit/documentation/HealthKit/HKQuantityType, doc://com.apple.healthkit/documentation/HealthKit/HKCategoryType, doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutType, or doc://com.apple.healthkit/documentation/HealthKit/HKCorrelationType classes ). If the user grants permission, your app can read these data types from the HealthKit store.

## Mentioned in

Accessing workout zone data Authorizing access to health data

## Discussion

Discussion HealthKit performs these requests asynchronously. If you call this method with a new data type (a type of data that the user hasn’t previously granted or denied permission for in this app), the system automatically displays the permission form, listing all the requested permissions. If the user has already chosen to grant or prohibit access to all of the types specified, HealthKit returns the request without prompting the user. important: In watchOS 6 and later, this method displays the permission form on Apple Watch, enabling independent HealthKit apps. In watchOS 5 and earlier, this method prompts the user to authorize the app on their paired iPhone. For more information, see Creating Independent watchOS Apps. Each data type has two separate permissions, one to read it and one to share it. You can make a single request, and include all the data types your app needs. Customize the messages displayed on the permissions sheet by setting the following keys: NSHealthShareUsageDescription customizes the message for reading data. NSHealthUpdateUsageDescription customizes the message for writing data. warning: You must set the usage keys, or your app will crash when you request authorization. For projects created using Xcode 13 or later, set these keys in the Target Properties list on the app’s Info tab. For projects created with Xcode 12 or earlier, set these keys in the apps Info.plist file. For more information, see Information Property List. After users have set the permissions for your app, they can always change them using either the Settings or the Health app. Your app appears in the Health app’s Sources tab, even if the user didn’t allow permission to read or share data.

## See Also

### Accessing HealthKit

- [authorizationStatus(for:)](healthkit/hkhealthstore/authorizationstatus(for:).md)
- [HKAuthorizationStatus](healthkit/hkauthorizationstatus.md)
- [getRequestStatusForAuthorization(toShare:read:completion:)](healthkit/hkhealthstore/getrequeststatusforauthorization(toshare:read:completion:).md)
- [HKAuthorizationRequestStatus](healthkit/hkauthorizationrequeststatus.md)
- [isHealthDataAvailable()](healthkit/hkhealthstore/ishealthdataavailable().md)
- [supportsHealthRecords()](healthkit/hkhealthstore/supportshealthrecords().md)
- [requestAuthorization(toShare:read:completion:)](healthkit/hkhealthstore/requestauthorization(toshare:read:completion:).md)
- [requestPerObjectReadAuthorization(for:predicate:completion:)](healthkit/hkhealthstore/requestperobjectreadauthorization(for:predicate:completion:).md)
- [handleAuthorizationForExtension(completion:)](healthkit/hkhealthstore/handleauthorizationforextension(completion:).md)
- [authorizationViewControllerPresenter](healthkit/hkhealthstore/authorizationviewcontrollerpresenter.md)
