# XRGoogleCloudFeature

This `OpenXRInteractionFeature` configures Android XR extensions `XR_ANDROID_google_cloud_auth` at runtime and provides XRGoogleCloudManager to manage Google Cloud API usages.

## Summary

### Inheritance

Inherits from: `OpenXRFeature`, [`Google.XR.Extensions.IXRSpatialSdk`](https://developer.android.com/develop/xr/unity/reference/interface/Google/XR/Extensions/IXRSpatialSdk)

| ### Public attributes ||
|---|---|
| `https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/XRGoogleCloudFeature#extensionstrings = "XR_EXT_future " + "XR_ANDROID_google_cloud_auth "` | `const string` The OpenXR Extension string. |
| `https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/XRGoogleCloudFeature#featureid = "com.google.xr.extensions.google_cloud"` | `const string` The feature ID string. |
| `https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/XRGoogleCloudFeature#uiname = "Android XR: Google Cloud"` | `const string` The UI name shows on the XR Plug-in Management panel, it helps users to understand validation errors and expected fixes. |

| ### Public static attributes ||
|---|---|
| `https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/XRGoogleCloudFeature#isextensionenabled => _extensionEnabled` | `bool` Gets if the required OpenXR extension is enabled. |
| `https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/XRGoogleCloudFeature#onauthresultreceived` | `Action< https://developer.android.com/develop/xr/unity/reference/struct/Google/XR/Extensions/XRGoogleCloudAuthResult#structGoogle_1_1XR_1_1Extensions_1_1XRGoogleCloudAuthResult >` The event fired when authentication errors have been triggered by other Google Cloud API calls. |

| ### Public functions ||
|---|---|
| `https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/XRGoogleCloudFeature#gettargetversion()` | `https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xrspatialsdkversions` Gets the target version of the given feature if applicable. |
| `https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/XRGoogleCloudFeature#trysetauthenticationasync(https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xrauthenticationstrategy strategy, string credential)` | `async Awaitable< OpenXRResultStatus >` Attempts to set authentication through an async operation. |
| `https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/XRGoogleCloudFeature#trysetstrategy(https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xrauthenticationstrategy strategy, string credential)` | `bool` Editor helper to set automatic strategy from scripts. |

## Public attributes

### ExtensionStrings

```c#
const string ExtensionStrings =
            "XR_EXT_future " +
            "XR_ANDROID_google_cloud_auth "
```
The OpenXR Extension string.

Used to check if this extensions is available or enabled.

### FeatureId

```c#
const string FeatureId = "com.google.xr.extensions.google_cloud"
```
The feature ID string.

### UiName

```c#
const string UiName = "Android XR: Google Cloud"
```
The UI name shows on the XR Plug-in Management panel, it helps users to understand validation errors and expected fixes.

## Public static attributes

### IsExtensionEnabled

```c#
bool IsExtensionEnabled => _extensionEnabled
```
Gets if the required OpenXR extension is enabled.

When OpenXR runtime is waiting, it returns `null`. Otherwise, it indicates whether the `XR_ANDROID_google_cloud_auth` extension is available on current device.

### OnAuthResultReceived

```c#
Action< XRGoogleCloudAuthResult > OnAuthResultReceived
```
The event fired when authentication errors have been triggered by other Google Cloud API calls.

If it's caused by [XRGoogleCloudAuthError.AuthError](https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xrgooglecloudautherror_autherror), you may call [TrySetAuthenticationAsync](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/XRGoogleCloudFeature#trysetauthenticationasync) manually with a valid configuration, and access Google Cloud APIs after succeed.

## Public functions

### GetTargetVersion

```c#
XRSpatialSdkVersions GetTargetVersion()
```
Gets the target version of the given feature if applicable.

### TrySetAuthenticationAsync

```c#
async Awaitable< OpenXRResultStatus > TrySetAuthenticationAsync(
  XRAuthenticationStrategy strategy,
  string credential
)
```
Attempts to set authentication through an async operation.


Details Parameters `strategy` The target strategy to be used for authentication. It must be a valid one other than [XRAuthenticationStrategy.None](https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xrauthenticationstrategy_none). `credential` The credentials passing for the given *strategy* . Ignored for [XRAuthenticationStrategy.Keyless](https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xrauthenticationstrategy_keyless). Invalid credential will result in [XRGoogleCloudAuthError.AuthError](https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xrgooglecloudautherror_autherror) from all calls to functions that depend on Cloud authorization. **Returns** The result of the async operation. Use OpenXRResultStatus.IsSuccess() to confirm if succeed. When failed with OpenXRResultStatus.StatusCode.PlatformError, check OpenXRResultStatus.nativeStatusCode for the failure reason. It might be [XrResultAndroid.KeylessNotSetup](https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xrresultandroid_keylessnotsetup), [XrResultAndroid.KeylessAuthFailed](https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xrresultandroid_keylessauthfailed) or common OpenXR errors from XrResult.

### TrySetStrategy

```c#
bool TrySetStrategy(
  XRAuthenticationStrategy strategy,
  string credential
)
```
Editor helper to set automatic strategy from scripts.


Details Parameters `strategy` The strategy to try on session start. `credential` The credential to be used on session start. **Returns** Returns true if it succeeded; otherwise, returns false.