Skip to content

Commit

Permalink
Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
SupianIDz committed Aug 5, 2023
1 parent 0ade9e2 commit ff699e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions app/Commands/CreateAuthCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,23 @@ public function handle(Config $config) : void

$gphoto = new GPhoto($this->argument('name'));

$url = $gphoto->oauth()->buildFullAuthorizationUri([
'access_type' => 'offline',
]);

$this->components->info('Auth URL : ' . $url);

// open auth url in browser
foreach (['xdg-open', 'sensible-browser', 'start'] as $command) {
$process = Process::run(sprintf('%s "%s"', $command, $gphoto->oauth()->buildFullAuthorizationUri([
'access_type' => 'offline',
])));
$process = Process::run(sprintf('%s "%s"', $command, $url));

if ($process->successful()) {
break;
}
}

$listener = new TokenListener($gphoto);
$listener->listen(
$this->components
);
$listener->listen($this->components);
}

/**
Expand Down
14 changes: 8 additions & 6 deletions app/Commands/ReloadAuthCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@ public function handle() : void
return;
}

$url = $gphoto->oauth()->buildFullAuthorizationUri([
'access_type' => 'offline',
]);

$this->components->info('Auth URL : ' . $url);

// open auth url in browser
foreach (['xdg-open', 'sensible-browser', 'start'] as $command) {
$process = Process::run(sprintf('%s "%s"', $command, $gphoto->oauth()->buildFullAuthorizationUri([
'access_type' => 'offline',
])));
$process = Process::run(sprintf('%s "%s"', $command, $url));

if ($process->successful()) {
break;
}
}

$listener = new TokenListener($gphoto);
$listener->listen(
$this->components
);
$listener->listen($this->components);
}

/**
Expand Down

0 comments on commit ff699e9

Please sign in to comment.