Skip to contents

Look up Apple's login settings and return an OAuthProvider for use with oauth_client(). This helper makes an OIDC discovery request during setup.

Usage

oauth_provider_apple(name = "apple")

Arguments

name

Optional provider name (default "apple")

Value

OAuthProvider object configured for Sign in with Apple

Details

Configure your client with:

  • Your Apple Services ID or App ID as client_id.

  • A client secret created with oauth_client_secret_apple() using your Apple developer key.

  • An HTTPS return address with a domain name; Apple does not accept localhost or IP addresses.

  • response_mode = "form_post" and oauth_form_post_ui() when requesting email or name.

Read identity information from the validated ID token's claims. Apple has no userinfo endpoint, so userinfo_required is FALSE. The one-time user payload that Apple may send with a form POST callback is not mapped into token@userinfo; do not rely on this helper to retrieve that payload. Apple's documented email_verified strings ("true" and "false") are normalized to logical values in validated claims after signature and issuer verification. Other providers retain the standard JSON Boolean requirement.

Examples

# Sign in with Apple requires an Apple Services ID, Team ID, key ID, and the
# corresponding P-256 private key. Network access is required for discovery.
if (interactive()) {
  apple_provider <- oauth_provider_apple()

  apple_secret <- oauth_client_secret_apple(
    client_id = "com.example.web",
    team_id = "ABCDEFGHIJ",
    key_id = "ABC123DEFG",
    private_key = openssl::read_key("AuthKey_ABC123DEFG.p8")
  )

  apple_client <- oauth_client(
    provider = apple_provider,
    client_id = "com.example.web",
    client_secret = apple_secret,
    redirect_uri = "https://example.com/oauth/callback",
    scopes = c("openid", "email", "name"),
    response_mode = "form_post"
  )
}