public function testGetQuerystringParams() { $scope = new Scope(['USER_READ', 'DATA_READ_WRITE']); $this->assertEquals(['scope' => 'USER_READ DATA_READ_WRITE'], $scope->getQuerystringParams()); $scope = new Scope([]); $this->assertSame([], $scope->getQuerystringParams()); }
/** * @param string $token * @param Scope $scope * @return Response */ public function rawTokenResponse($token, Scope $scope) { $params = ['access_token' => $token, 'expires_in' => 3600, 'token_type' => 'bearer', 'refresh_token' => 'refresh_XYZ987'] + $scope->getQuerystringParams(); $tokenData = json_encode($params); return new Response(200, [], $tokenData); }
/** * @return array */ private function getParams() { $payload = ['scope' => $this->scope->getQuerystringParams()['scope'], 'iss' => $this->clientConfig->getParams()['client_id'], 'sub' => $this->clientConfig->getParams()['subject'], 'aud' => $this->getTokenEndpoint(), 'exp' => $this->baseTime + self::EXPIRES_IN_TIME, 'nbf' => $this->baseTime - self::NOT_BEFORE_TIME, 'iat' => $this->baseTime, 'jti' => '', 'typ' => '']; $assertion = JWT::encode($payload, $this->clientConfig->getParams()['client_secret']); return [['name' => 'grant_type', 'contents' => self::GRANT_TYPE], ['name' => 'assertion', 'contents' => $assertion]]; }