diff --git a/src/Token/AppleAccessToken.php b/src/Token/AppleAccessToken.php index 3820f53..28affb6 100644 --- a/src/Token/AppleAccessToken.php +++ b/src/Token/AppleAccessToken.php @@ -23,6 +23,11 @@ class AppleAccessToken extends AccessToken */ protected $isPrivateEmail; + /** + * @var array + */ + protected $idTokenPayload; + /** * Constructs an access token. * @@ -80,6 +85,8 @@ public function __construct(array $keys, array $options = []) if (isset($payload['is_private_email'])) { $this->isPrivateEmail = $payload['is_private_email']; } + + $this->idTokenPayload = $payload; } parent::__construct($options); @@ -116,4 +123,12 @@ public function isPrivateEmail() { return $this->isPrivateEmail; } + + /** + * @return array + */ + public function getIdTokenPayload() + { + return $this->idTokenPayload; + } } diff --git a/test/src/Token/AppleAccessTokenTest.php b/test/src/Token/AppleAccessTokenTest.php index d9005bf..d42da1f 100644 --- a/test/src/Token/AppleAccessTokenTest.php +++ b/test/src/Token/AppleAccessTokenTest.php @@ -15,16 +15,17 @@ class AppleAccessTokenTest extends TestCase */ public function testCreatingAccessToken() { + $tokenPayload = [ + 'sub' => '123.abc.123', + 'email_verified' => true, + 'email' => 'john@doe.com', + 'is_private_email' => true + ]; $externalJWTMock = m::mock('overload:Firebase\JWT\JWT'); $externalJWTMock->shouldReceive('decode') ->with('something', 'examplekey') ->once() - ->andReturn([ - 'sub' => '123.abc.123', - 'email_verified' => true, - 'email' => 'john@doe.com', - 'is_private_email' => true - ]); + ->andReturn($tokenPayload); $accessToken = new AppleAccessToken(['examplekey'], [ 'access_token' => 'access_token', @@ -38,6 +39,7 @@ public function testCreatingAccessToken() $this->assertEquals('access_token', $accessToken->getToken()); $this->assertEquals('john@doe.com', $accessToken->getEmail()); $this->assertTrue($accessToken->isPrivateEmail()); + $this->assertEquals($tokenPayload, $accessToken->getIdTokenPayload()); $this->assertTrue(true); }