【发布时间】:2016-04-08 21:07:31
【问题描述】:
我正在尝试通过 Picasa 的 API 将照片上传到相册,但是遇到了身份验证错误。
我的凭据在程序启动时已成功验证,而不是在我尝试上传照片或添加相册时
这是我的代码:
import gdata.photos.service
import gdata.media
import gdata.geo
gd_client = gdata.photos.service.PhotosService()
gd_client.email = 'username@gmail.com'
gd_client.password = 'password'
gd_client.source = 'exampleCo-exampleApp-1'
gd_client.ProgrammaticLogin()
username = 'username'
albums = gd_client.GetUserFeed(user=username)
album_id = albums.entry[0].gphoto_id.text
album_url = '/data/feed/api/user/%s/albumid/%s' % (username, album_id)
path = 'C:\Users\Public\Pictures\Sample Pictures\Desert.jpg'
album = gd_client.InsertAlbum(title='New album', summary='This is an album')
photo = gd_client.InsertPhotoSimple(album_url, 'New Photo',
'Uploaded using the API', path, content_type='image/jpeg')
这是我在尝试添加相册或上传照片时收到的错误:
Traceback (most recent call last):
File "C:/Users/1020071/Documents/test.py", line 19, in <module>
album = gd_client.InsertAlbum(title='New album', summary='This is an album')
File "C:\Python27\lib\site-packages\gdata\photos\service.py", line 358, in InsertAlbum
raise GooglePhotosException(e.args[0])
GooglePhotosException: (403, 'Forbidden', 'Modification only allowed with api authentication.')
这是我一直关注的指南:https://developers.google.com/picasa-web/docs/1.0/developers_guide_python#request-a-list-of-albums
【问题讨论】:
-
不是问题,但在路径中使用原始字符串或正斜杠
标签: python api authentication photo picasa