-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathAppleToken.php
More file actions
32 lines (25 loc) · 825 Bytes
/
AppleToken.php
File metadata and controls
32 lines (25 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace SocialiteProviders\Apple;
use Carbon\CarbonImmutable;
use Lcobucci\JWT\Configuration;
class AppleToken
{
private Configuration $jwtConfig;
public function __construct(Configuration $jwtConfig)
{
$this->jwtConfig = $jwtConfig;
}
public function generate(): string
{
$now = CarbonImmutable::now();
$token = $this->jwtConfig->builder()
->issuedBy(config('services.apple.team_id'))
->issuedAt($now)
->expiresAt($now->addHour())
->permittedFor(Provider::URL)
->relatedTo(config('services.apple.client_id'))
->withHeader('kid', config('services.apple.key_id'))
->getToken($this->jwtConfig->signer(), $this->jwtConfig->signingKey());
return $token->toString();
}
}