Skip to content

Commit e84f0b6

Browse files
authored
Merge pull request #731 from glaubinix/f/create-installation-token
Fixed: installation access token endpoint
2 parents 33d6c9e + 15d0116 commit e84f0b6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/Github/Api/Apps.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class Apps extends AbstractApi
1616
* @param int $userId An optional user id on behalf of whom the
1717
* token will be requested
1818
*
19+
* @link https://developer.github.com/v3/apps/#create-a-new-installation-token
20+
*
1921
* @return array token and token metadata
2022
*/
2123
public function createInstallationToken($installationId, $userId = null)
@@ -25,7 +27,7 @@ public function createInstallationToken($installationId, $userId = null)
2527
$parameters['user_id'] = $userId;
2628
}
2729

28-
return $this->post('/installations/'.rawurlencode($installationId).'/access_tokens', $parameters);
30+
return $this->post('/app/installations/'.rawurlencode($installationId).'/access_tokens', $parameters);
2931
}
3032

3133
/**

test/Github/Tests/Api/AppTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@
44

55
class AppTest extends TestCase
66
{
7+
/**
8+
* @test
9+
*/
10+
public function shouldCreateInstallationTokenForInstallation()
11+
{
12+
$result = [
13+
'token' => 'v1.1f699f1069f60xxx',
14+
'expires_at' => '2016-07-11T22:14:10Z',
15+
];
16+
$installationId = 'installation1';
17+
18+
$api = $this->getApiMock();
19+
$api->expects($this->once())
20+
->method('post')
21+
->with('/app/installations/'.$installationId.'/access_tokens', [])
22+
->willReturn($result);
23+
24+
$this->assertEquals($result, $api->createInstallationToken($installationId));
25+
}
26+
727
/**
828
* @test
929
*/

0 commit comments

Comments
 (0)