Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class AppleClientSecret

  1. Object
  2. AppleClientSecret

ImplementsClientRegistration.ClientSecretSupplier

The client secret of Sign in with Apple, which is not a text Apple issues but a token this server signs: an ES256 JWT naming the team, the client and Apple, signed with the .p8 key downloaded from the developer account.

CommonOAuth2Provider.APPLE.getBuilder("apple")
        .clientId("com.example.web")          // the Services ID
        .clientSecretSupplier(AppleClientSecret.fromFile(teamId, keyId, "AuthKey.p8"))
        .build();

A secret is good for an hour and is made again when it has under five minutes left, so signing costs one signature an hour and not one a sign-in.

Fields

public static final String AUDIENCE = "https://appleid.apple.com"Who the token is for.

Constructors

public AppleClientSecret(String teamId, String keyId, String privateKeyPem) throws IOException

Methods

public static AppleClientSecret fromFile(String teamId, String keyId, String path) throws IOExceptionAppleClientSecret(String, String, String) reading the key from a file.
public synchronized void setClock(Clock clock)The clock the secret’s times are read from; for tests.
public synchronized String getClientSecret(ClientRegistration registration)The secret to send now.

Inherited methods

Field details

AUDIENCE

public static final String AUDIENCE = "https://appleid.apple.com"
Who the token is for.

Constructor details

AppleClientSecret

public AppleClientSecret(String teamId, String keyId, String privateKeyPem) throws IOException

Parameters

teamId String
the ten-character Team ID of the developer account
keyId String
the Key ID of the Sign in with Apple key
privateKeyPem String
the text of the .p8 file

Method details

fromFile

public static AppleClientSecret fromFile(String teamId, String keyId, String path) throws IOException
AppleClientSecret(String, String, String) reading the key from a file.

setClock

public synchronized void setClock(Clock clock)
The clock the secret’s times are read from; for tests.

getClientSecret

public synchronized String getClientSecret(ClientRegistration registration)
The secret to send now.