OAuthRequest.Builder


class OAuthRequest.Builder


Builder for constructing new instance of OAuth request.

Summary

Public constructors

Builder(context: Context)

Public functions

OAuthRequest
@RequiresApi(value = 26)
build()

Build the request instance specified by this builder

OAuthRequest.Builder
setAuthProviderUrl(authProviderUrl: Uri)

Set the url of the auth provider site.

OAuthRequest.Builder
setClientId(clientId: String)

Set the client id of this OAuth request.

OAuthRequest.Builder

Set the code challenge for authentication with PKCE (proof key for code exchange).

OAuthRequest.Builder
setRedirectUrl(redirectUrl: Uri)

Set the redirect url the companion app registered to, so that the response will be routed from the auth server back to the companion.

Public constructors

Builder

Added in 1.0.0
Builder(context: Context)
Parameters
context: Context

The Context of the app sending the auth request.

Public functions

build

Added in 1.0.0
@RequiresApi(value = 26)
fun build(): OAuthRequest

Build the request instance specified by this builder

setAuthProviderUrl

Added in 1.0.0
fun setAuthProviderUrl(authProviderUrl: Uri): OAuthRequest.Builder

Set the url of the auth provider site. Appending query parameters in this uri is optional, it is recommended to let the builder append query parameters automatically through the use of setters (no setter is required for the builder to append the redirect_uri).

setClientId

Added in 1.0.0
fun setClientId(clientId: String): OAuthRequest.Builder

Set the client id of this OAuth request. With this setter called. the builder appends the "client_id" to the requestUrl.

setCodeChallenge

Added in 1.0.0
fun setCodeChallenge(codeChallenge: CodeChallenge): OAuthRequest.Builder

Set the code challenge for authentication with PKCE (proof key for code exchange). With this setter called, the builder appends the "code_challenge", "code_challenge_method" and "response_type" queries to the requestUrl.

setRedirectUrl

Added in 1.0.0
fun setRedirectUrl(redirectUrl: Uri): OAuthRequest.Builder

Set the redirect url the companion app registered to, so that the response will be routed from the auth server back to the companion.

Calling this method is optional. If the redirect URL is not specified, it will be automatically set to WEAR_REDIRECT_URL_PREFIX or WEAR_REDIRECT_URL_PREFIX_CN for rest of the world or China, respectively.

Note, the app package name should NOT be included here, it will be appended to the end of redirect_uri automatically in Builder.build.