简体   繁体   中英

How to upload to google docs without having to type user and password?

I want to use my google account so when someone uploads a document through my site, it gets uploaded to google docs. I have registered an app and I tried some of the tips here - http://code.google.com/apis/accounts/docs/OAuth2.html and here - http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#ResumableUpload but I can't seem to figure out the correct thing to do. It keeps sending me to a page with a 'I Allow' button, so I would authorize my app for my account. Is there a way I can do this just once and then skip this part? Or is there some other way to avoid showing my visitors 'I allow' page? I am using PHP.

Just use client login and hard code your user name and password into your code.

    address = 'username'
    key = 'password'

    client_login = gdata.client.GDClient()
    login_token = client_login.request_client_login_token(address, key, 'docs', 'writely')
    client = gdata.docs.client.DocsClient(login_token)
    client.ssl = True
    client.http_client.debug = False

Since this is done server side no one will be able to see your username and password. That's how to do it in python, but the approach should be very similar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM