我正在使用Django-socila-auth 插件。它使用 google API 进行 Oauth 1.0 身份验证。问题是有人将它与谷歌python API(gdata)一起使用。我的意思是如何将存储在 django-social-auth 模型中的 auth session_token 应用于我的 api 调用。
你能帮我用代码从模型中获取这个令牌并应用于 gdata.PhotoService() 实例吗?现在是这样的:
#getting model instance from django-social-auth model
association = Association.objects.get(user=request.user)
google_session_token=association.handle
google_secret=association.secret
#token string from django-social-auth
#model Association field "handle" looks like:
#google_session_token = '.......XG84PjwytqJkvr8WQhDxm1w-JplWK5zPndSHB13f.........'
gd_client = gdata.photos.service.PhotosService()
gd_client.debug = 'true'
gd_client.auth_token = google_session_token
#image.image is a file field, but problem not in this.
#it tries to send file in debug text.
#It just recieves 403 unauthorised callback.
photo = gd_client.InsertPhotoSimple(
'/data/feed/api/user/default/albumid/default', 'New Photo',
'Uploaded using the API', image.image, content_type='image/jpeg')
我收到错误
403 Invalid token string.
我知道它也需要秘密,但如何将其应用于 API 进行身份验证?(获得发布照片的授权。)。顺便说一句,我添加了 Picassa 提要 URL,作为社交身份验证请求权限的选项字符串,因此我在向 google 授权时要求提供 Picassa 提要权限。
顺便提一句。我使用的谷歌教程是:这里 我知道它是 Oauth 1.0 而不是 AusSub,但问题是: