I spent the whole week trying to figure out what is wrong with my code and 
so far I have no idea.
When I tried to use the ClientLogin method asking a user to enter his userid 
and password, everything 
worked faultless and then I put it on the Marketplace, Google unlisted my 
application asking me to 
change to the 2-legged OAuth.    Well I tried to make the changes and it 
didn't work.   

Any ideas why it fails would be greatly appreciated.     

I try to get a list of all users for a domain that subscribes to my app.

Here is my manifest file.

<?xml version="1.0" encoding="UTF-8" ?>
<ApplicationManifest 
xmlns="http://schemas.google.com/ApplicationManifest/2009";>

  <!-- Support info to show in the marketplace & control panel -->
  <Support>
    <!-- URL for application setup as an optional redirect during the 
install -->
    <Link rel="setup" 
href="http://www.buzexpenses.com/google/setup.php?domain=${DOMAIN_NAME}"; />

    <!-- URL explaining how customers get support. -->
    <Link rel="support" href="http://www.buzexpenses.com/contact.html"; />

    <!-- URL that is displayed to admins during the deletion process, to 
specify policies such as data retention, how to claim accounts, etc. -->
    <Link rel="deletion-policy" 
href="http://www.buzexpenses.com/deletion-policy.html"; />
  </Support>

  <!-- Name and description pulled from message bundles -->
  <Name>SAASEXpense</Name>
  <Description>Expense management for small and medium-sized 
businesses</Description>

  <!-- Show this link in Google's universal navigation for all users -->
  <Extension id="navLink" type="link">
    <Name>SAASExpense</Name>
    
<Url>http://www.buzexpenses.com/google?from=google&amp;domain=${DOMAIN_NAME}</Url>
    <!-- This app also uses the Calendar API -->
    <Scope ref="calendarFeed"/>
    <!-- This app also uses the User API -->
    <Scope ref="userFeed"/>
  </Extension>

  <!-- Declare our OpenID realm so our app is white listed -->
  <Extension id="realm" type="openIdRealm">
    <Url>http://www.buzexpenses.com</Url>
  </Extension>

  <!-- Need access to the Calendar feed -->
  <Scope id="calendarFeed">
    <Url>http://www.google.com/calendar/feeds/</Url>
    <Reason>This application shows the next Calendar event.</Reason>
  </Scope>
  <!-- Need access to the Users feed -->
  <Scope id="userFeed">
    <Url>http://apps-apis.google.com/a/feeds/user/#readonly</Url>
    <Reason>This application manages Users.</Reason>
  </Scope>

</ApplicationManifest>

Here is my code:

<?php
require_once 'common.php';
require_once 'Zend/Loader.php';
require_once 'Zend/Oauth/Consumer.php';
require_once 'Zend/Gdata/Gapps.php';
require_once 'Zend/Gdata/Gapps/UserQuery.php';
require_once 'Zend/Gdata/Gapps/UserFeed.php';

/**
 * Setup OAuth
 */
require_once 'Zend/Oauth/Consumer.php';
$options = array(
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
    'version' => '1.0',
    'signatureMethod' => 'HMAC-SHA1',
    'consumerKey' => 'www.buzexpenses.com.apps.googleusercontent.com',
    'consumerSecret' => 'XXXXXX'
);


if(isset($_GET['domain'])) {
  $domain = $_GET['domain'];
}

echo "$DOMAIN=$domain";

/**
 * Create HTTP Client object which adds OAuth Authorization
 * headers to outbound requests.
 */
$consumer = new Zend_Oauth_Consumer($options);
$token = new Zend_Oauth_Token_Access();
$httpClient = $token->getHttpClient($options);

$userClient = new Zend_Gdata_Gapps($httpClient);
$userClient->enableRequestDebugLogging('foo.txt');
$userQuery = new Zend_Gdata_Gapps_UserQuery($domain);
$usersFeed = $userClient->getUserFeed($userQuery);


$userArr = array();

foreach ($usersFeed as $users) {
  $login = $userEntry->getLogin();
  $name = $userEntry->getName();
  $userArrEntry = array();
  $userArrEntry['username'] = $login->getUsername();
  $userArrEntry['admin'] = $login->getAdmin();
  $userArrEntry['first_name'] = $name->getGivenName();
  $userArrEntry['last_name'] = $name->getFamilyName();
  $userArr[$login->getUserName()] = $userArrEntry;
}
....

Here is the error:

Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected 
response code 200, got 403 <HTML> <HEAD> <TITLE>Invalid OAuth 
target.</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Invalid 
OAuth target.</H1> <H2>Error 403</H2> </BODY> </HTML> ' in 
/home/buzexpen/public_html/google/Zend/Gdata/App.php:708 Stack trace: #0 
/home/buzexpen/public_html/google/Zend/Gdata.php(221): 
Zend_Gdata_App->performHttpRequest('GET', 'https://apps-ap...', Array, NULL, 
NULL, NULL) #1 /home/buzexpen/public_html/google/Zend/Gdata/App.php(874): 
Zend_Gdata->performHttpRequest('GET', 'https://apps-ap...', Array) #2 
/home/buzexpen/public_html/google/Zend/Gdata/Gapps.php(202): 
Zend_Gdata_App->get('https://apps-ap...', NULL) #3 
/home/buzexpen/public_html/google/Zend/Gdata/App.php(762): 
Zend_Gdata_Gapps->get('https://apps-ap...', NULL) #4 
/home/buzexpen/public_html/google/Zend/Gdata/App.php(205): 
Zend_Gdata_App->importUrl('https://apps-ap...', 'Zend_Gdata_Gapp...', NULL) 
#5 /home/buzexpen/public_html/google/Zend/Gdat in *
/home/buzexpen/public_html/google/Zend/Gdata/App.php* on line *708*
*
*
*

Connecting to: apps-apis.google.com:443

GET /a/feeds/civida.com/user/2.0 HTTP/1.1
Host: apps-apis.google.com
Connection: close
User-Agent: MyCompany-MyApp-1.0 Zend_Framework_Gdata/1.11.0dev
Accept-encoding: identity
Authorization: OAuth 
realm="",oauth_consumer_key="www.buzexpenses.com.apps.googleusercontent.com",oauth_nonce="a76bada5696c8d3e2b007420e7460006",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1302123011",oauth_version="1.0",oauth_signature="h51ZBueahMEfqPVcYUv5t7nLIyY%3D"

Closing socket

Closing socket

HTTP/1.1 403 Invalid OAuth target.
Content-Type: text/html; charset=UTF-8
Date: Wed, 06 Apr 2011 20:50:12 GMT
Expires: Wed, 06 Apr 2011 20:50:12 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Connection: close

<HTML>
<HEAD>
<TITLE>Invalid OAuth target.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Invalid OAuth target.</H1>
<H2>Error 403</H2>
</BODY>
</HTML>

*

-- 
You received this message because you are subscribed to the Google Groups 
"Google Apps Domain Information and Management APIs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-apps-mgmt-apis?hl=en.

Reply via email to