我有一个想要与 Flickr 同步的 Web 应用程序。我不希望用户必须登录 Flickr,所以我打算使用单一登录。我相信我需要做这样的事情:
import flickrapi
flickr = flickrapi.FlickrAPI(myKey, mySecret)
(token, frob) = flickr.get_token_part_one(perms='write', my_auth_callback)
flickr.get_token_part_two((token, frob,))
flickr.what_have_you(...
我不知道 my_auth_callback 应该是什么样子。我怀疑它必须将我的登录信息发布到 flickr。我可以手动执行一次 get_token_part_one 步骤,然后在 get_token_part_two 中重新使用它吗?
编辑
伍布尔有。以下是我使用 Django shell 和 flickrapi 库写下的一些明确说明。
import flickrapi
api_key = "xxxx...xxxx"
api_secret = "xxxx...xxxx"
_flickr = flickrapi.FlickrAPI(api_key, api_secret)
_flickr.web_login_url("write")
# Go to that url.
# That sends you back to the callback url you set by "editing the
# authentication workflow" on your flicks admin page located on the site.
# This callback url will contain a frob in the form
# xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx-xxxxxxxx
_flickr.get_token("xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx-xxxxxxxx")
# That returns the token. Then test with
import flickrapi
from django.conf import settings
_flickr = flickrapi.FlickrAPI(api_key, api_secret, token=api_token)
_flickr.groups_pools_getGroups()