Skip to content

Commit 356187c

Browse files
committed
feat: implement GitHub client authentication in service provider
1 parent 39f884b commit 356187c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Providers/GithubProjectServiceProvider.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace CSlant\GithubProject\Providers;
44

5+
use Github\AuthMethod;
6+
use Github\Client;
57
use Illuminate\Support\ServiceProvider;
68

79
class GithubProjectServiceProvider extends ServiceProvider
@@ -28,6 +30,12 @@ public function register(): void
2830
$this->registerConfigs();
2931

3032
$this->registerCommands();
33+
34+
$this->app->singleton(Client::class, function () {
35+
$client = new Client();
36+
$client->authenticate(config('github-project.github.access_token'), null, AuthMethod::ACCESS_TOKEN);
37+
return $client;
38+
});
3139
}
3240

3341
/**

src/Services/WebhookService.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace CSlant\GitHubProject\Services;
44

5-
use Github\AuthMethod;
65
use Github\Client;
76

87
class WebhookService
@@ -12,7 +11,6 @@ class WebhookService
1211
public function __construct(Client $client)
1312
{
1413
$this->client = $client;
15-
$this->client->authenticate((string) config('github-project.github.access_token'), null, AuthMethod::ACCESS_TOKEN);
1614
}
1715

1816
public function eventApproved(string $event): bool

0 commit comments

Comments
 (0)