Hi

I am using the premier edition and am trying to get the list of users
for my domain, I have enabled 2 legged oauth. Here's the code:
-----------------------------------------------------------------------
import oauth
import gdata.apps
import gdata.apps.service
import urllib
import gdata.urlfetch
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
gdata.service.http_request_handler = gdata.urlfetch

CONSUMER_KEY = mydomain.com'
CONSUMER_SECRET = 'secret_key_for_my_domain'

USERS_URL = 'https://apps-apis.google.com/a/feeds/domain/user/2.0'

class OAuthSample(webapp.RequestHandler):

  def get(self):
    consumer = oauth.OAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET)

    request = oauth.OAuthRequest.from_consumer_and_token(
        consumer, http_method='GET', http_url=USERS_URL,
parameters=None)

    request.sign_request(oauth.OAuthSignatureMethod_HMAC_SHA1(),
consumer, None)

    headers = request.to_header()

    client = gdata.apps.service.AppsService()

    uri = '%s' % request.http_url

    feed = client.GetFeed(uri, extra_headers=headers,
converter=gdata.apps.UserFeedFromString)

    for entry in feed.entry:
      self.response.out.write('%s, %s<br/>' % (entry.title.text,
entry.email[0].address))

application = webapp.WSGIApplication([('/',
OAuthSample)],debug=True)

def main():
   run_wsgi_app(application)

if __name__ == "__main__":
   main()
-----------------------------------------------------------------------

but all am getting is the follwoing error:

RequestError: {'status': 401, 'body': '<HTML>\n<HEAD>\n<TITLE>Unknown
authorization header</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF"
TEXT="#000000">\n<H1>Unknown authorization header</H1>\n<H2>Error 401</
H2>\n</BODY>\n</HTML>\n', 'reason': ''}

Can you please help me out?

Thanks
Ajay
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Apps 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-apis?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to