Before proceeding with account authorization, make sure that you have:

1. The Google Home app (GHA) installed on your mobile iOS device, set up with at least one home (structure) on your Google Account.
2. At least one of these device types supported for the Sample App in the home:
   - Color Temperature Light
   - Dimmable Light
   - Door Lock
   - Extended Color Light
   - Fan
   - Google Border Router
   - Google Camera
   - Google Doorbell
   - Occupancy Sensor
   - On/Off Light
   - On/Off Plug-in Unit
   - Temperature Sensor
   - Thermostat
   - Window Covering
3. Two devices for testing the sample automation.

Prior to using devices through the Home APIs, they must controllable from
GHA.

## Run the Sample App

From the Xcode IDE, select a physical device to deploy.

> [!NOTE]
> **Note:** iOS simulators are not supported due to the App Attest requirements.

Before authorizing an account, verify that the Sample App is configured with the
appropriate OAuth scope for your project. By default, the Sample App source code
uses the `https://www.googleapis.com/auth/home.platform.v2` scope. Many features
in the Sample App are gated by the `home.platform.v2` scope and require partner
approval to access. To authorize and use the Sample App with the standard
`https://www.googleapis.com/auth/home.platform.selected.devices` scope, manually
switch `homePlatformOAuthScope` to `HomePlatformOAuthScope.v1` in
`GoogleHomeAPISampleIOS.swift` as described in
[Build the app](https://developers.home.google.com/apis/ios/sample-app/build.md.txt#build_the_app).

The first time running it, you'll be asked to allow access
to a home on your Google Account. This grants the Sample App permission to
access and control the structures and devices in that home.

If you don't have a structure, the user can create one during the permission
flow without having to use GHA.

The app's default permission behavior will differ depending on
whether or not the app was registered on the Google Home Developer Console.

> [!WARNING]
> **Important:** The Google Home Developer Console is not yet available for registration.

**If an app is not registered in the Developer Console** , it will be in
an *unverified* state. This is recommended for testing use of the Home APIs:

- Only users [registered as test users in the OAuth
  console](https://developers.home.google.com/apis/eap/ios/oauth#consent) can grant
  permissions for the app. There is a limit of 100 test users for an unverified
  app.

- An unverified app will have access to devices of any device types that are
  supported by OAuth for the Home APIs (the list of device types in the
  Developer Console). All devices in a structure will be granted.

**If
an app is registered in the Developer Console** and
has been approved for access to one or more device types, and [brand
verification has been completed for
OAuth](https://developers.google.com/identity/protocols/oauth2/production-readiness/brand-verification),
it will be in a *verified* state. This state is required for launching an app to
production:

- Test user limits no longer apply. Any user can grant permission to the app.
- The user can only grant permission to the device types that were approved in the Developer Console.

Tap **Connect** in the upper-right of the app.

- If there are any homes connected to your account, choose a home to grant permission to. If no devices are found in the chosen home, you can set up a device of your choosing in that home using the Google Home app (GHA). Remember, only these device types have support for control in this Sample App:
  - Color Temperature Light
  - Dimmable Light
  - Door Lock
  - Extended Color Light
  - Fan
  - Google Border Router
  - Google Camera
  - Google Doorbell
  - Occupancy Sensor
  - On/Off Light
  - On/Off Plug-in Unit
  - Temperature Sensor
  - Thermostat
  - Window Covering
- If there are no homes connected to your account, you will need to set up a home. To do so, use the GHA. Then attempt to connect the Sample App again.

- ![iOS Sample App authorization flow (Step 1)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-oauth-01.png)

  The user of the app clicks **Connect**.
- ![iOS Sample App authorization flow (Step 2)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-oauth-02.png)

  Allow google.com to be used for Sign In.
- ![iOS Sample App authorization flow (Step 3)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-oauth-03.png)

  The user selects the Google Account to use.
- ![iOS Sample App authorization flow (Step 4)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-oauth-04.png)

  The user selects a home to grant permissions for.
- ![iOS Sample App authorization flow (Step 5)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-oauth-05.png)

  The user selects a home to grant permissions for.
- ![iOS Sample App authorization flow (Step 6)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-oauth-06.png)

  The user is returned to the home view.
**Figure 1**: iOS Sample App authorization flow

Once you have successfully granted permission to a home that features devices,
you will be taken to the devices view. You can control the devices and observe
their state changes through the Sample App.

## Revoke authorization

You can revoke previously-granted access through [Google Account
settings](https://myaccount.google.com/).
- ![iOS Sample App revoke authorization flow (Step 1)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-revoke-01.png)

  The user of the app clicks more_horiz on the top-right corner.
- ![iOS Sample App revoke authorization flow (Step 2)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-revoke-02.png)

  The user clicks **About**.
- ![iOS Sample App revoke authorization flow (Step 3)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-revoke-03.png)

  The user clicks **Revoke app permission**.
- ![iOS Sample App revoke authorization flow (Step 4)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-revoke-04.png)

  The user selects **Delete all connections you have with iOS Sample App**.
- ![iOS Sample App revoke authorization flow (Step 5)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-revoke-05.png)

  The user clicks **Confirm**.
- ![iOS Sample App revoke authorization flow (Step 6)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-revoke-06.png)

  A pop-up window appears to confirm disconnection of Google Account and iOS Sample App.
- ![iOS Sample App revoke authorization flow (Step 7)](https://developers.home.google.com/static/apis/ios/images/ios-sample-app-oauth-01.png)

  The user is returned to the home view.
**Figure 2**: iOS Sample App revoke authorization flow