Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7401303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:25:51+00:00 2026-05-29T04:25:51+00:00

With python-gdata 2.0.14, I used the following pieces of code to create and upload

  • 0

With python-gdata 2.0.14, I used the following pieces of code to create and upload documents:

# To create a document
import gdata.docs
import gdata.docs.client
from gdata.data import MediaSource

gdClient = gdata.docs.client.DocsClient(source="my-app")
gdClient.ssl = True
gdClient.ClientLogin("login", "pa$$word", gdClient.source)
ms = MediaSource(file_path="temp.html", content_type="text/html")
entry = gdClient.Upload(ms, "document title")
print "uploaded, url is", entry.GetAlternateLink().href

and

# To update a document
entry.title.text = "updated title"
entry = gdClient.Update(entry, media_source=ms, force=True)
print "updated, url is", entry.GetAlternateLink().href

However, this code does no longer work with python-gdata 2.0.16 because DocsClient class does no more have Upload and Update functions.

I tried to use this

# Try to create a document
gdClient = gdata.docs.client.DocsClient(source="my-app")
gdClient.ssl = True
gdClient.ClientLogin("login", "pa$$word", gdClient.source)
ms = MediaSource(file_path="temp.html", content_type="text/html")
entry = gdata.docs.data.Resource(type=gdata.docs.data.DOCUMENT_LABEL, title="document title")
self.resource = gdClient.CreateResource(entry, media=ms)

… but I get this error:

gdata.client.Unauthorized: Unauthorized - Server responded with: 401, 'Token invalid'

Can anybody tell me where’s my mistake and how should I use that new API?

P.S. The documentation hasn’t been updated and still uses the old-style code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:25:54+00:00Added an answer on May 29, 2026 at 4:25 am

    I was having issues with this recently too. This worked for me:

    import gdata.docs.data
    import gdata.docs.client
    
    client = gdata.docs.client.DocsClient(source='your-app')
    client.api_version = "3"
    client.ssl = True
    client.ClientLogin("your@email.com", "password", client.source)
    
    filePath = "/path/to/file"
    newResource = gdata.docs.data.Resource(filePath, "document title")
    
    media = gdata.data.MediaSource()
    media.SetFileHandle(filePath, 'mime/type')
    
    newDocument = client.CreateResource(newResource, create_uri=gdata.docs.client.RESOURCE_UPLOAD_URI, media=media)
    

    Edit: Added the packages to import to avoid confusion

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to install gdata python library client,receiving following errors: running install running build running
I'm using the gdata-python-client library (http://code.google.com/p/gdata-python-client/) to insert contacts into a Google account. When
When I upload PDF to Google Docs (using Python's gdata library), I get link
Using the gdata API for Python , how do I create or list events
I'm using exactly the code in the examples from here: http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_python.html#Auth Still no dice.
I'm wondering if it's possible to retrieve a simple GoogleDoc (via gdata python client
Having previously obtained a post ID from a call to gdata.blogger.client.add_post() ... post =
I'm using the Python client library for the Picasa Web Albums API to upload
Is there any way to search playlists on youtube using gdata-python-client? As for documentation
Python works on multiple platforms and can be used for desktop and web applications,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.