简体   繁体   English

Google App Engine Python的Flickr OAuth

[英]Flickr OAuth from Google App Engine Python

I have a weird problem with Flickr OAuth on Google App Engine: 我对Google App Engine上的Flickr OAuth有一个奇怪的问题:

I'm requesting for oauth token and secret from Flickr using the code attached.. it fails most of time when tested on App Engine.. Flickr returns a page saying 我正在使用随附的代码向Flickr请求oauth令牌和机密。.在App Engine上进行测试时,大多数时间它都失败了。.Flickr返回页面说

"Flickr has the hiccups. We're looking into the problem right now..." “ Flickr遇到了麻烦。我们现在正在调查问题...”

At first I thought it might be the problem with Flickr.. but then if I copied the URL into chrome directly, I could get the oauth token and secret.. So I thought it could be the problem with my code fetching the URL.. but in fact, with the same piece of code, I'm also able to get token and secret at localhost .. 起初我以为可能是Flickr的问题。但是,如果我直接将URL复制到chrome中,则可以获得oauth令牌和密码。。所以我认为这可能是我的代码获取URL的问题。但实际上,使用同一段代码,我也能够在localhost ..获得令牌和密码。

Now I'm really confused.. because this used to work perfectly until recently.. is there any update on App Engine dev server that might cause the problem? 现在,我真的很困惑..因为这一直到最近都可以正常工作.. App Engine开发服务器上是否有任何更新可能导致此问题? Please help!!! 请帮忙!!!

        url = "http://www.flickr.com/services/oauth/request_token"
        params = {
            "oauth_timestamp": str(int(time())),
            "oauth_signature_method": "HMAC-SHA1",
            "oauth_version": "1.0",
            "oauth_nonce": sha1(str(random())).hexdigest(),
            "oauth_callback": API_CALLBACK,
            "oauth_consumer_key": API_KEY,
        }
        # Setup the Consumer with the key-secret given by Flickr
        consumer = oauth2.Consumer(key=API_KEY, secret=API_SECRET)

        # Create request
        req = oauth2.Request(method="GET", url=url, parameters=params)

        # Create signature
        signature = oauth2.SignatureMethod_HMAC_SHA1().sign(req, consumer, None)

        # Add the Signature to the request
        req['oauth_signature'] = signature

        h = httplib2.Http()
        resp, content = h.request(req.to_url(), "GET")

Update: I changed the code a little bit, keep requesting if I don't get the token (given a max try allowed). 更新:我稍微修改了代码,如果没有得到令牌,则继续请求(允许最大尝试)。 It works... still, it is very annoying that I have to write such work-around. 它的工作原理...仍然很烦人,我必须编写这样的解决方法。 Would appreciate if better alternative is available! 如果有更好的替代方法,将不胜感激!

您需要使用https而不是http(请参见上面的注释线程)

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

相关问题 适用于Google App Engine Python的OAuth - OAuth for Google App Engine Python 在Google App Engine上使用Python导入Flickr api时出错 - Error while importing Flickr api using Python on Google App Engine 从 OAuth2 注销 - Google App Engine/Python - Logout from OAuth2 - Google App Engine/Python 在Google App Engine中使用OAuth Python服务 - Using OAuth Python service with Google App Engine Google App Engine服务器到服务器OAuth Python - Google App Engine Server to Server OAuth Python Oauth + Aeoid + Python + Google App Engine + Google文档 - Oauth + Aeoid +Python + Google App Engine + Google documents 如何使用OAuth从Python应用程序访问Google App Engine端点API? - How can I access Google App Engine endpoints API from Python application with use OAuth? 是否可以在没有OAuth2身份验证对话框的情况下从Google App-Engine(python)连接和查询BigQuery表? - Is it possible to connect and query a BigQuery table from Google App-Engine (python) without OAuth2 authentication dialog? 如何通过Google App Engine Python将OAuth用于用户名和密码 - How to use OAuth for username and password with Google App Engine Python Google App Engine(Python)ImportError:Google App Engine中没有名为oauth2的模块 - Google app engine(python) ImportError: No module named oauth2 in google app engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM