mirror of
https://github.com/sakaljurgis/actions-api.git
synced 2026-07-08 22:07:40 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Google;
|
||||
|
||||
use Google\Client;
|
||||
|
||||
class ApiAuthService
|
||||
{
|
||||
/**
|
||||
* @throws \Google\Exception
|
||||
*/
|
||||
public function getAccessToken(): string
|
||||
{
|
||||
$client = new Client();
|
||||
$serviceAccountKeyPath = env('GOOGLE_APPLICATION_CREDENTIALS');
|
||||
$client->setAuthConfig($serviceAccountKeyPath);
|
||||
$client->addScope('https://www.googleapis.com/auth/cloud-platform');
|
||||
$client->fetchAccessTokenWithAssertion();
|
||||
|
||||
// todo - cache, refresh, etc
|
||||
$accessToken = $client->getAccessToken();
|
||||
|
||||
return $accessToken['access_token'];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user