Skip to content

Commit 116f366

Browse files
committed
Installations: Add create access token endpoint
1 parent 51eb698 commit 116f366

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/Github/Api/Installations.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Github\Api;
4+
5+
/**
6+
* @link https://developer.github.com/early-access/integrations/authentication/
7+
* @author Nils Adermann <[email protected]>
8+
*/
9+
class Installations extends AbstractApi
10+
{
11+
/**
12+
* Create an access token for an installation
13+
*
14+
* @param int $installationId An integration installation id
15+
* @param int $userId An optional user id on behalf of whom the
16+
* token will be requested
17+
*
18+
* @return array token and token metadata
19+
*/
20+
public function createAccessToken($installationId, $userId = null)
21+
{
22+
$parameters = array();
23+
if ($userId) {
24+
$paramters['user_id'] = $userId;
25+
}
26+
return $this->post('/installations/'.rawurlencode($installationId).'/access_tokens', $parameters);
27+
}
28+
}

lib/Github/Client.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ public function api($name)
210210
$api = new Api\Gists($this);
211211
break;
212212

213+
case 'installation':
214+
case 'installations':
215+
$api = new Api\Installations($this);
216+
break;
217+
213218
case 'issue':
214219
case 'issues':
215220
$api = new Api\Issue($this);

0 commit comments

Comments
 (0)