简体   繁体   English

如何上传到谷歌文档而无需输入用户名和密码?

[英]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. 我已经注册了一个应用,我在这里尝试了一些提示 - http://code.google.com/apis/accounts/docs/OAuth2.html和此处 - http://code.google.com/apis/documents/ docs / 3.0 / developers_guide_protocol.html#ResumableUpload但我似乎无法弄清楚要做的正确的事情。 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. 我正在使用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. 这是在python中如何做到这一点,但方法应该非常相似。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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