# OAuthRequest

Artifact: [androidx.wear:wear-phone-interactions](https://developer.android.com/jetpack/androidx/releases/wear) [View Source](https://cs.android.com/search?q=file:androidx/wear/phone/interactions/authentication/OAuthRequest.kt+class:androidx.wear.phone.interactions.authentication.OAuthRequest) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear#1.0.0)

*** ** * ** ***


```
public final class OAuthRequest
```

<br />

*** ** * ** ***

The OAuth request to be sent to the server to start the OAuth 2 authentication flow.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/wear/phone/interactions/authentication/OAuthRequest.Builder` Builder for constructing new instance of OAuth request. |

| ### Constants |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/phone/interactions/authentication/OAuthRequest#WEAR_REDIRECT_URL_PREFIX()` The default google-specific custom URL to route the response from the auth server back to the 1P companion app, which then forwards it to the 3P app that made the request on the wear device. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/phone/interactions/authentication/OAuthRequest#WEAR_REDIRECT_URL_PREFIX_CN()` The default google-specific custom URL in China to route the response from the auth server back to the 1P companion app, which then forwards it to the 3P app that made the request on the wear device. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/phone/interactions/authentication/OAuthRequest#getPackageName()()` The package name of the app sending the auth request. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/phone/interactions/authentication/OAuthRequest#getRedirectUrl()()` The redirect url the companion app is registered to. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/wear/phone/interactions/authentication/OAuthRequest#getRequestUrl()()` The Url of the auth request. |

## Constants

### WEAR_REDIRECT_URL_PREFIX

```
public static final @NonNull String WEAR_REDIRECT_URL_PREFIX
```

The default google-specific custom URL to route the response from the auth server back to the 1P companion app, which then forwards it to the 3P app that made the request on the wear device.

### WEAR_REDIRECT_URL_PREFIX_CN

```
public static final @NonNull String WEAR_REDIRECT_URL_PREFIX_CN
```

The default google-specific custom URL in China to route the response from the auth server back to the 1P companion app, which then forwards it to the 3P app that made the request on the wear device.

## Public methods

### getPackageName

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear#1.0.0)

```
public final @NonNull String getPackageName()
```

The package name of the app sending the auth request.

### getRedirectUrl

Added in [1.1.1](https://developer.android.com/jetpack/androidx/releases/wear#1.1.1)

```
public final @NonNull String getRedirectUrl()
```

The redirect url the companion app is registered to. If it doesn't exist, an empty string will be returned.

### getRequestUrl

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear#1.0.0)

```
public final @NonNull Uri getRequestUrl()
```

The Url of the auth request.

The request is expected to create a URL with the following format:

```
    https://authorization-server.com/auth?client_id=XXXXX
    &redirect_uri=https://wear.googleapis.com/3p_auth/mypackagename
    &response_type=code
    &code_challenge=XXXXX...XXX
    &code_challenge_method=S256
```