我已经成功地使用了谷歌的PicasaAPI从过去的6个月左右。 今天我开始出错了
raise GooglePhotosException(e.args[0])
GooglePhotosException: (403, 'Forbidden', 'Authorization required')
我检查了我的证件。在
^{pr2}$从昨天开始一切都很顺利。有人有线索吗?在
关于python的Picasa
的示例也不起作用。
URL
#!/usr/bin/python2.5
import gdata.photos.service
import gdata.media
import gdata.geo
gd_client = gdata.photos.service.PhotosService()
gd_client.email = '=change=' # Set your Picasaweb e-mail address...
gd_client.password = '=change=' # ... and password
gd_client.source = 'api-sample-google-com'
gd_client.ProgrammaticLogin()
albums = gd_client.GetUserFeed()
for album in albums.entry:
print 'Album: %s (%s)' % (album.title.text, album.numphotos.text)
photos = gd_client.GetFeed('/data/feed/api/user/default/albumid/%s?kind=photo' % (album.gphoto_id.text))
for photo in photos.entry:
print ' Photo:', photo.title.text
tags = gd_client.GetFeed('/data/feed/api/user/default/albumid/%s/photoid/%s?kind=tag' % (album.gphoto_id.text, photo.gphoto_id.text))
for tag in tags.entry:
print ' Tag:', tag.title.text
comments = gd_client.GetFeed('/data/feed/api/user/default/albumid/%s/photoid/%s?kind=comment' % (album.gphoto_id.text, photo.gphoto_id.text))
for comment in comments.entry:
print ' Comment:', comment.content.text
完全回溯
Traceback (most recent call last):
File "/Users/mac/Picasa_API.py", line 158, in <module>
check_api()
File "/Users/mac/Picasa_API.py", line 140, in check_api
albums = gd_client.GetUserFeed()
File "/Users/mac/destipak/env/lib/python2.7/site-packages/gdata/photos/service.py", line 235, in GetUserFeed
return self.GetFeed(uri, limit=limit)
File "/Users/mac/destipak/env/lib/python2.7/site-packages/gdata/photos/service.py", line 180, in GetFeed
raise GooglePhotosException(e.args[0])
gdata.photos.service.GooglePhotosException: (403, 'Forbidden', 'Authorization required')
我也碰到过这个。电子邮件/密码验证似乎已关闭,我们需要切换到OAuth2。看到了吗 https://groups.google.com/forum/#!topic/Google-Picasa-Data-API/4meiAJ40l3E
下面是我用来让OAuth2身份验证与Picasa一起工作的代码。首先,您需要通过googledeveloper控制台在https://console.developers.google.com/创建一个客户机ID,然后必须将客户机机密作为JSON下载并将文件名传递给OAuth2Login。在
第一次运行此代码时,必须通过web浏览器对客户端进行授权,并将获得的代码粘贴到应用程序中。然后,凭证存储在凭证存储区指定的文件中。在
相关问题 更多 >
编程相关推荐