/**
  * Retrieve OAuth and refresh tokens from Google API as per:
  * http://code.google.com/apis/accounts/docs/OAuth2.html#SS
  * @param str $client_id
  * @param str $client_secret
  * @param str $code_refresh_token Either the refresh token or Google-provided code
  * @param str $grant_type Either 'refresh_token' or 'authorization_code'
  * @param str $redirect_uri
  * @return Object with access_token and refresh_token member vars
  */
 public function getOAuthTokens($client_id, $client_secret, $code_refresh_token, $grant_type, $redirect_uri = null)
 {
     //prep access token request URL
     $access_token_request_url = "https://accounts.google.com/o/oauth2/token";
     $fields = array('client_id' => urlencode($client_id), 'client_secret' => urlencode($client_secret), 'grant_type' => urlencode($grant_type));
     if ($grant_type == 'refresh_token') {
         $fields['refresh_token'] = $code_refresh_token;
     } elseif ($grant_type == 'authorization_code') {
         $fields['code'] = $code_refresh_token;
     }
     if (isset($redirect_uri)) {
         $fields['redirect_uri'] = $redirect_uri;
     }
     //get tokens
     $tokens = $this->api_accessor->rawPostApiRequest($access_token_request_url, $fields, true);
     return $tokens;
 }