🔒 Persist Trakt authentication tokens to config JSON file
This commit is contained in:
parent
f19afc41f0
commit
dd7196572c
4 changed files with 17 additions and 3 deletions
|
|
@ -6,12 +6,14 @@ namespace App\Commands;
|
|||
|
||||
use App\Services\Trakt;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class TraktLogin extends Command
|
||||
{
|
||||
protected $signature = 'trakt:login';
|
||||
protected $description = 'Login and get new token.';
|
||||
public function handle(Trakt $trakt, Repository $config): int
|
||||
|
||||
public function handle(Trakt $trakt, Repository $config, Filesystem $files): int
|
||||
{
|
||||
$data = [
|
||||
'client_id' => $config->get('trakt.app_id'),
|
||||
|
|
@ -31,6 +33,7 @@ class TraktLogin extends Command
|
|||
}
|
||||
|
||||
$this->line("TRAKT_DEVICE_RESP='" . json_encode($body) . "'");
|
||||
$config->set('trakt.login.device', $body);
|
||||
|
||||
$data = [
|
||||
'client_id' => $config->get('trakt.app_id'),
|
||||
|
|
@ -48,6 +51,8 @@ class TraktLogin extends Command
|
|||
$body = $resp->json();
|
||||
$this->line("TRAKT_OAUTH_RESP='" . json_encode($body) . "'");
|
||||
$this->line('TRAKT_OAUTH_TOKEN=' . $body['access_token']);
|
||||
$config->set('trakt.login.oauth', $body);
|
||||
$files->put($config->get('trakt.path'), json_encode($config->get('trakt'), JSON_PRETTY_PRINT));
|
||||
|
||||
return static::SUCCESS;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue