---
title: "requestAuthorization(sensors:completion:)"
framework: sensorkit
role: symbol
role_heading: Type Method
path: "sensorkit/srsensorreader/requestauthorization(sensors:completion:)"
---

# requestAuthorization(sensors:completion:)

Requests user permission to read one or more sensors.

## Declaration

```swift
class func requestAuthorization(sensors: Set<SRSensor>, completion: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
class func requestAuthorization(sensors: Set<SRSensor>) async throws
```

## Parameters

- `sensors`: One or more sensors your app requests.
- `completion`: A closure to run after the framework determines user authorization.

## Discussion

Discussion Call this function for sensors in which authorizationStatus is SRAuthorizationStatus.notDetermined to display a prompt that requests user authorization. When the prompt dismisses, the framework calls the completion closure. Your delegate needs to wait for a call to sensorReader(_:didChange:) to determine whether the user approves sensor access. If you pass a sensor into this function for which the user already answered the in-app prompt, the framework cancels the prompt with SRError.Code.promptDeclined. When the user has already answered the prompt for a particular sensor, its authorizationStatus is SRAuthorizationStatus.authorized or SRAuthorizationStatus.denied. The user may change the authorization status for a sensor in Settings > Privacy > Research Sensor & Usage Data. For more information about the authorization workflow, see Configuring your project for sensor reading.

## See Also

### Checking user authorization

- [authorizationStatus](sensorkit/srsensorreader/authorizationstatus.md)
- [SRAuthorizationStatus](sensorkit/srauthorizationstatus.md)
