Skip to content

Instantly share code, notes, and snippets.

@mhlipson
Created May 17, 2012 00:45
Show Gist options
  • Save mhlipson/2715245 to your computer and use it in GitHub Desktop.
Save mhlipson/2715245 to your computer and use it in GitHub Desktop.
Update oAuth credentail
<?php
$url = "https://accounts.google.com/o/oauth2/token";
$fields = array(
'grant_type' => 'refresh_token',
'client_id' => 'CLIENT_ID',
'client_secret' => 'CLIENT_SECRET',
'refresh_token' => 'REFRESH_TOKEN'
);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$key = json_decode($output);
$key = $key->access_token;
echo $key . "\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment