Skip to content

Commit

Permalink
Merge pull request 1EdTech#57 from packbackbooks/oncall-391-fix-lti-h…
Browse files Browse the repository at this point in the history
…eader

ONCALL-391 Fix LTI Header
  • Loading branch information
jlegault-packback authored Jun 17, 2022
2 parents 806625d + 81130ac commit 7af0341
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/LtiServiceConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getAccessToken(ILtiRegistration $registration, array $scopes)

// Get Access
$request = new ServiceRequest(static::METHOD_POST, $url);
$request->setBody(json_encode($authRequest));
$request->setPayload(['form_params' => $authRequest]);
$response = $this->makeRequest($request);

$tokenData = $this->getResponseBody($response);
Expand Down
12 changes: 12 additions & 0 deletions src/ServiceRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ServiceRequest implements IServiceRequest
private $method;
private $url;
private $body;
private $payload;
private $accessToken;
private $contentType = 'application/json';
private $accept = 'application/json';
Expand All @@ -31,6 +32,10 @@ public function getUrl(): string

public function getPayload(): array
{
if (isset($this->payload)) {
return $this->payload;
}

$payload = [
'headers' => $this->getHeaders(),
];
Expand Down Expand Up @@ -64,6 +69,13 @@ public function setBody(string $body): IServiceRequest
return $this;
}

public function setPayload(array $payload): IServiceRequest
{
$this->payload = $payload;

return $this;
}

public function setAccept(string $accept): IServiceRequest
{
$this->accept = $accept;
Expand Down

0 comments on commit 7af0341

Please sign in to comment.