Exemple #1
0
 /**
  * Goes through the client authorization routine. This routine both
  * redirects a user to the Google Accounts authorization screen as well as
  * handle the response from the authorization service to retrieve the
  * authorization code then exchange it for an access token. This method
  * also removes the authorization code from the URL to keep things pretty.
  * Details on how the apiClient implements authorization can be found here:
  * http://code.google.com/p/google-api-php-client/source/browse/trunk/src/auth/apiOAuth2.php#84
  * If an authorization error occurs, the exception is caught and the error
  * message is saved in $error.
  */
 public function authenticate()
 {
     try {
         $accessToken = $this->client->authenticate();
         $this->storage->set($accessToken);
         // Keep things pretty. Removes the auth code from the URL.
         if ($_GET['code']) {
             header("Location: {$this->controllerUrl}");
         }
     } catch (Google_AuthException $e) {
         $this->errorMsg = $e->getMessage();
     }
 }