/[drupal]/contributions/modules/services_oauth/services_oauth.pages.inc
ViewVC logotype

Diff of /contributions/modules/services_oauth/services_oauth.pages.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Fri May 8 21:12:30 2009 UTC revision 1.2, Mon Jun 1 09:31:24 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: services_oauth.pages.inc,v 1.1 2009/05/08 21:12:30 hugowetterberg Exp $
3    
4    function _services_oauth_authorized() {
5      return t('The application has been authorized');
6    }
7    
8  /**  /**
9   * Form for granting access to the consumer   * Form for granting access to the consumer
# Line 29  function _services_oauth_authorize() { Line 33  function _services_oauth_authorize() {
33        header('Location: ' . drupal_substr($_SERVER['REQUEST_URI'], 1), TRUE, 302);        header('Location: ' . drupal_substr($_SERVER['REQUEST_URI'], 1), TRUE, 302);
34      }      }
35    
36      if (!user_access('access services')) {      if (!user_access('services oauth authorize consumers')) {
37        drupal_set_message(t('You are not authorized to allow external services access to this system.'), 'error');        drupal_set_message(t('You are not authorized to allow external services access to this system.'), 'error');
38        return drupal_access_denied();        return drupal_access_denied();
39      }      }
# Line 162  function _services_oauth_authorize_submi Line 166  function _services_oauth_authorize_submi
166    
167    $got_permission = $got_permission || $values['full_access'];    $got_permission = $got_permission || $values['full_access'];
168    
169    // Pick the callback url apart and add the token parameter    if (isset($parameters['oauth_callback'])) {
170    $callback = parse_url($parameters['oauth_callback']);      // Pick the callback url apart and add the token parameter
171    $query = array();      $callback = parse_url($parameters['oauth_callback']);
172    parse_str($callback['query'], $query);      $query = array();
173    $query['oauth_token'] = $token->key;      parse_str($callback['query'], $query);
174    $callback['query'] = http_build_query($query, 'idx_', '&');      $query['oauth_token'] = $token->key;
175        $callback['query'] = http_build_query($query, 'idx_', '&');
176    // Return to the consumer site  
177    header('Location: ' . _services_oauth_glue_url($callback), TRUE, 302);      // Return to the consumer site
178    exit;      header('Location: ' . _services_oauth_glue_url($callback), TRUE, 302);
179        exit;
180      }
181      else {
182        drupal_goto('oauth/authorized');
183      }
184  }  }
185    
186  function _services_oauth_glue_url($parsed) {  function _services_oauth_glue_url($parsed) {
# Line 201  function _services_oauth_request_token() Line 210  function _services_oauth_request_token()
210      print $server->fetch_request_token($req);      print $server->fetch_request_token($req);
211    }    }
212    catch (OAuthException $e) {    catch (OAuthException $e) {
213        var_dump($e); die;
214      drupal_set_header('HTTP/1.0 401 Unauthorized: ' . $e->getMessage());      drupal_set_header('HTTP/1.0 401 Unauthorized: ' . $e->getMessage());
215      drupal_set_header(sprintf('WWW-Authenticate: OAuth realm="%s"', url('', array('absolute'=>TRUE))));      drupal_set_header(sprintf('WWW-Authenticate: OAuth realm="%s"', url('', array('absolute'=>TRUE))));
216    }    }
# Line 277  function _services_oauth_user_applicatio Line 287  function _services_oauth_user_applicatio
287      $form['applications'] = $apps;      $form['applications'] = $apps;
288    }    }
289    
290    if (user_access('access services', $account)) {    if (user_access('services oauth authorize consumers', $account)) {
291      $auth = array(      $auth = array(
292        '#type' => 'fieldset',        '#type' => 'fieldset',
293        '#title' => t('Authorizations'),        '#title' => t('Authorizations'),

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2