Add command to refresh token
This commit is contained in:
parent
6741d95073
commit
03d6a9f152
52
src/Commands/TokenRefresh.php
Normal file
52
src/Commands/TokenRefresh.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Intuit\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Intuit\Traits\ProviderTokenTrait;
|
||||
|
||||
// @todo this should move to leenooks/intuit
|
||||
class TokenRefresh extends Command
|
||||
{
|
||||
use ProviderTokenTrait;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'intuit:token:refresh'
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Refresh an access token';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
* @throws \Intuit\Exceptions\NotTokenException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$to = $this->providerToken($this->argument('user'));
|
||||
|
||||
$old = $to->refresh_token;
|
||||
|
||||
$x = $to->refreshToken();
|
||||
|
||||
dump([
|
||||
'access'=>$to->access_token,
|
||||
'old'=>$old,
|
||||
'refresh'=>$to->refresh_token,
|
||||
'expires'=>(string)$to->refresh_token_expires_at,
|
||||
'x'=>$x,
|
||||
]);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ namespace Intuit\Providers;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Intuit\Commands\{AccountGet,InvoiceGet,PaymentGet,TaxCodeGet};
|
||||
use Intuit\Commands\{AccountGet,InvoiceGet,PaymentGet,TaxCodeGet,TokenRefresh};
|
||||
|
||||
/**
|
||||
* Class IntuitServiceProvider.
|
||||
@ -27,6 +27,7 @@ class IntuitServiceProvider extends ServiceProvider
|
||||
InvoiceGet::class,
|
||||
PaymentGet::class,
|
||||
TaxCodeGet::class,
|
||||
TokenRefresh::class,
|
||||
]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user