KnpLabs/php-github-api

Authentication of token and method with enterprise GitHub account

bkuppala95 opened this issue · 3 comments

How to authenticate token and method with enterprise GitHub account.

public function sendGit() {
$username = $this->token;
$method = Github\Client::AUTH_ACCESS_TOKEN;
$client = new \Github\Client(nill, nill, 'https://github.organization.com/' );
$client->authenticate($username, $method);
$client->api('issue')->create($this->owner, $this->repo, ['title' => 'SlackBot Issue ', 'body' => $this->getIssue()]);
$this->say('The issue is created');

I have implemented code this way but is unable to connect with my organization GitHub.

@bkuppala95 and what error do you get? Can you provide some more info on result you get?

@acrobat What I am trying to do is create an issue in Github from slack. Connection is successfully set up but when I submit the data from slack the issue is not created and the error is as below.

Successfully connected
PHP Fatal error: Uncaught Github\Exception\RuntimeException: Issues are disabled for this repo in /home/ubuntu/bot/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionT
hrower.php:123
Stack trace:
#0 /home/ubuntu/bot/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php(31): Github\HttpClient\Plugin\GithubExceptionThrower->Github\HttpClient\Plugin{closure}()
#1 /home/ubuntu/bot/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php(124): Http\Client\Promise\HttpFulfilledPromise->then()
#2 /home/ubuntu/bot/vendor/php-http/client-common/src/PluginChain.php(48): Github\HttpClient\Plugin\GithubExceptionThrower->handleRequest()
#3 /home/ubuntu/bot/vendor/php-http/client-common/src/PluginChain.php(63): Http\Client\Common\PluginChain->Http\Client\Common{closure}()
#4 /home/ubuntu/bot/vendor/php-http/client-common/src/PluginClient.php(90): Http\Client\Common\PluginChain->__invoke()
#5 /home/ubuntu/bot/vendor/php-http/client-common/src/HttpMethodsClient.php(148): Http\Client\Common\ in /home/ubuntu/bot/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExce
ptionThrower.php on line 123

@bkuppala95 The expection that is returned explains the problem very well. Issues are disabled for this repo so the repository you are trying to create an issue in has issues disabled. This is also mentioned in the github docs

Any user with pull access to a repository can create an issue. If issues are disabled in the repository, the API returns a 410 Gone status.
https://docs.github.com/en/rest/reference/issues#create-an-issue