title: How do i refresh google token if expired?
body: <p>I am Creating YouTube Broadcast and it successfully working.</p>
  <pre><code>$client = new Google_Client();
  $client-&gt;setClientId($OAUTH2_CLIENT_ID);
  $client-&gt;setClientSecret($OAUTH2_CLIENT_SECRET);
  $client-&gt;setScopes('https://www.googleapis.com/auth/youtube');
  
  // $client-&gt;refreshToken($accessToken);
  // // $client-&gt;refreshToken($accessToken);
  // $newToken = $client-&gt;getAccessToken();
  // echo &quot;new token : &quot;. $newToken;
  $client-&gt;setAccessToken($accessToken);
  try {
  
  
  
  // Define service object for making API requests.
  $service = new Google_Service_YouTube($client);
  
  // Define the $liveBroadcast object, which will be uploaded as the request body.
  $liveBroadcast = new Google_Service_YouTube_LiveBroadcast();
  
  
  // Add 'contentDetails' object to the $liveBroadcast object.
  $liveBroadcastContentDetails = new Google_Service_YouTube_LiveBroadcastContentDetails();
  $liveBroadcastContentDetails-&gt;setEnableClosedCaptions(true);
  $liveBroadcastContentDetails-&gt;setEnableContentEncryption(true);
  $liveBroadcastContentDetails-&gt;setEnableDvr(true);
  $liveBroadcastContentDetails-&gt;setRecordFromStart(true);
  $liveBroadcastContentDetails-&gt;setStartWithSlate(true);
  $liveBroadcast-&gt;setContentDetails($liveBroadcastContentDetails);
  
  // Add 'snippet' object to the $liveBroadcast object.
  $liveBroadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
  $liveBroadcastSnippet-&gt;setScheduledStartTime($start_date_time);
  $liveBroadcastSnippet-&gt;setTitle($class_name);
  $liveBroadcast-&gt;setSnippet($liveBroadcastSnippet);
  
  // Add 'status' object to the $liveBroadcast object.
  $liveBroadcastStatus = new Google_Service_YouTube_LiveBroadcastStatus();
  $liveBroadcastStatus-&gt;setPrivacyStatus('unlisted');
  $liveBroadcast-&gt;setStatus($liveBroadcastStatus);
  
  
  $response = $service-&gt;liveBroadcasts-&gt;insert('snippet,contentDetails,status', $liveBroadcast);
  return ($response-&gt;id);
  
  
  } catch (Google_Service_Exception $e) {
  print_r($e);
  } catch (Google_Exception $e) {
  print_r($e);
  } 
  </code></pre>
  <p>but after some time Authorization failed.
  token has been expired and unable to create broadcast.
  I tried to refresh token but not working please help.</p>
  <p><a href="https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/insert?apix=true%5B%5D%5B1%5D" rel="nofollow noreferrer">https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/insert?apix=true[][1]</a></p>