【问题标题】:Google UrlFetch Service with CouchDB OAuth带有 CouchDB OAuth 的 Google UrlFetch 服务
【发布时间】:2012-08-15 12:03:33
【问题描述】:

根据this,Google Apps 可以“获取资源并通过 Internet 与其他主机通信”。我想使用 OAuth 访问我的 couchdb 实例。 CouchDB supports OAuth。我打算这样做:

  1. 在 CouchDB 配置中启用 OAuth 身份验证处理程序:{couch_httpd_oauth, oauth_authentication_handler}
  2. 为我想要提供的数据库定义一个数据库阅读器
  3. 使用脚本工具测试设置。
  4. 设置 Google App 应用程序以使用 CouchDB OAuth 授权用户。

这里有人在这个特定的设置上有 cmets 吗? 有人可以提供一个简单的测试脚本(最好是 python)来访问 OAuth 1.0 端点吗?

【问题讨论】:

    标签: python google-app-engine oauth couchdb


    【解决方案1】:

    对于 Python 中的 CouchDB OAuth 示例,您可以使用 script from wiki page 来了解 OAuth 授权。

    但是,由于它是用单行样式编写的,所以这里是流版本:

    import oauth
    import httplib
    
    URL='http://localhost:5984/_session'
    CONSUMER_KEY = 'example.com'
    CONSUMER_SECRET = 'sekr1t'
    TOKEN='user1'
    SECRET='tokensekr1t'
    
    consumer = oauth.OAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET)
    token = oauth.OAuthToken(TOKEN, SECRET)
    req = oauth.OAuthRequest.from_consumer_and_token(
        consumer, token=token, http_method='GET', http_url=URL, parameters={}
    )
    req.sign_request(oauth.OAuthSignatureMethod_HMAC_SHA1(), consumer,token)
    
    con = httplib.HTTPConnection('localhost', 5984)
    con.request('GET', URL,headers=req.to_header())
    print con.getresponse().read()
    

    【讨论】:

      猜你喜欢
      • 2014-04-20
      • 2013-07-17
      • 2012-11-24
      • 1970-01-01
      • 1970-01-01
      • 2016-05-30
      • 1970-01-01
      • 1970-01-01
      • 2012-11-10
      相关资源
      最近更新 更多