pub struct AppleClientSecretSigner { /* private fields */ }Expand description
Generates and renews Sign in with Apple client secrets.
Each secret is an ES256 JWT with the Team ID as iss, the OAuth client ID
as sub, and https://appleid.apple.com as aud. Secrets last one hour by
default. A cached secret is reused until less than five minutes remain.
Clones share the same cache.
Implementations§
Source§impl AppleClientSecretSigner
impl AppleClientSecretSigner
Sourcepub fn new(
team_id: &str,
key_id: &str,
private_key_pem: &[u8],
) -> Result<Self, AppleClientSecretError>
pub fn new( team_id: &str, key_id: &str, private_key_pem: &[u8], ) -> Result<Self, AppleClientSecretError>
Create a signer from the Team ID, the key ID, and the .p8 private key.
private_key_pem is the PKCS #8 PEM file that Apple issues for a
Sign in with Apple key. The key is checked with a trial signature.
Sourcepub fn with_lifetime(
self,
lifetime: Duration,
) -> Result<Self, AppleClientSecretError>
pub fn with_lifetime( self, lifetime: Duration, ) -> Result<Self, AppleClientSecretError>
Return a signer whose secrets remain valid for lifetime.
The lifetime must be between 10 minutes and 15,777,000 seconds (about six months). Fractions of a second are ignored. The returned signer starts with an empty cache.
Sourcepub fn client_secret(&self, client_id: &str) -> AuthResult<String>
pub fn client_secret(&self, client_id: &str) -> AuthResult<String>
Return a valid client secret for client_id.
The signer reuses its cached secret for the same client ID until less than five minutes of validity remain. Otherwise it signs a new secret.