$token = $config
->builder()
->issuedBy($teamId)
->permittedFor($aud)
->issuedAt($iat)
->expiresAt($exp)
->relatedTo($sub)
->withHeader('kid', $keyId)
->withHeader('type', 'JWT')
->withHeader('alg', 'ES256')
->getToken($config->signer(), $config->signingKey());
return $token->toString();
$teamId = self::TEAM_ID;
$keyId = self::KEY_ID;
$sub = self::CLIENT_ID;
$aud = 'https://appleid.apple.com';
$iat = strtotime('now');
$exp = strtotime('+1 day');
$keyContent = file_get_contents(storage_path('services/auth/AuthKey.p8'));
if (!$keyContent){
return '';
}
return JWT::encode(
[
'iss' => $teamId,
'iat' => $iat,
'exp' => $exp,
'aud' => $aud,
'sub' => $sub,
],
$keyContent,
'ES256',
$keyId
);