handles Google refresh token
This commit is contained in:
parent
b5adf7dbd0
commit
dee2522676
2 changed files with 16 additions and 5 deletions
|
@ -35,9 +35,17 @@ function addVideoToFediList($videoUrl) {
|
|||
echo "‼️ Error: token.json missing or invalid. Authenticate first.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
//print_r($token);
|
||||
|
||||
// === Refresh token if expired ===
|
||||
if (isset($token['expires_at']) && time() >= $token['expires_at']) {
|
||||
if (isset($token['expires_at'])) {
|
||||
$secondsLeft = $token['expires_at'] - time();
|
||||
if ($secondsLeft > 0) {
|
||||
$minutes = floor($secondsLeft / 60);
|
||||
$seconds = $secondsLeft % 60;
|
||||
echo "⏳ Token expires in $minutes minutes and $seconds seconds.\n";
|
||||
} else {
|
||||
echo "🔄 Access token expired. Refreshing...\n";
|
||||
|
||||
$refreshResponse = curlPost('https://oauth2.googleapis.com/token', [
|
||||
|
@ -58,6 +66,8 @@ function addVideoToFediList($videoUrl) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// === Extract video ID ===
|
||||
if (!preg_match('/(?:v=|\/)([a-zA-Z0-9_-]{11})/', $videoUrl, $matches)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue