Search code examples
google-app-enginepython-2.7google-oauthgoogle-apps-marketplace

Calling Google Apps Marketplace UpgradeableApp API with Python Appengine App


Is it possible to call the Google Apps Marketplace UpgradeableApp API from a Python Appengine App? The only examples available seem to be for Java / Ruby.

Our App is written in Python / Appengine so we would like to use this - any example code woul dbe much appreciated.

In Ruby it seems to be simple as:

consumer = OAuth::Consumer.new(consumer_key, consumer_secret, { site: "https://www.googleapis.com" }) 
resp = consumer.request(:put, "/appsmarket/v2/upgradableApp/#{listingId}/#{cwsId}/#{domain}") puts resp.code+"\n" puts resp.body

Cheers, Ian.


Solution

  • OK I have now solved this - python code below, although not documented you can use the oauth2 library to provide the oauth authentication part:

    url = 'https://www.googleapis.com/appsmarket/v2/upgradableApp/oldlisting/newlisting/mybeacon.biz'
    
    consumer_key = 'key'
    consumer_secret = 'secret'
    
    consumer = oauth.Consumer(consumer_key, consumer_secret)
    
    client = oauth.Client(consumer)
    
    # Step 1: Get a request token. This is a temporary token that is used for
    # having the user authorize an access token and to sign the request to obtain
    # said access token.
    
    resp, content = client.request(url, "PUT")
    

    Hope this helps you out...