Skip to content

Commit

Permalink
oauth2 token always responds with json
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Mar 7, 2015
1 parent 4181991 commit 1687823
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions library/PSX/Oauth2/Provider/TokenAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use PSX\Data\RecordAbstract;
use PSX\Data\RecordInfo;
use PSX\Data\ReaderInterface;
use PSX\Data\WriterInterface;
use PSX\Oauth2\Authorization\Exception\ErrorException;

/**
Expand Down Expand Up @@ -81,7 +82,8 @@ protected function doHandle()
$accessToken = $this->grantTypeFactory->get($grantType)->generateAccessToken($credentials, $parameters);

$this->response->setStatus(200);
$this->setBody($accessToken);

$this->setBody($accessToken, WriterInterface::JSON);
}
catch(ErrorException $e)
{
Expand All @@ -91,7 +93,8 @@ protected function doHandle()
$error->setState(null);

$this->response->setStatus(400);
$this->setBody($error);

$this->setBody($error, WriterInterface::JSON);
}
catch(\Exception $e)
{
Expand All @@ -101,7 +104,8 @@ protected function doHandle()
$error->setState(null);

$this->response->setStatus(400);
$this->setBody($error);

$this->setBody($error, WriterInterface::JSON);
}
}
}

0 comments on commit 1687823

Please sign in to comment.