大家好,有任何建议可以提供帮助,
问题:
是否可以使用“Google Domains API”访问非域名Google Profiles ?
对于非域名关联的Google帐户帐户,只能使用“Google API”吗?
有没有办法使用标准OAuth 2.0客户端凭据而不是服务帐户来完成以下任务?
背景:
我正在尝试使用Google Domains API for Python从Linux设备上传.jpg图像,并插入我的个人Google Profiles /帐户 .
此帐户不属于域名,我的应用程序不会访问其他任何Google用户的数据 . 我创建了一个服务帐户和PKCS 12密钥,其中包含我用于授权的“所有者”权限 . 注意我没有创建域范围授权,因为我认为没有与我的个人Google帐户关联的域 .
Getting Error 403 trying to access Google+ Domains using a Service Account
googleapiclient.errors.HttpError: <HttpError 403 when requesting
https://www.googleapis.com/upload/plusDomains/v1/people/me/media/cloud?
uploadType=multipart&alt=json returned "Forbidden">
执行media() . insert()到集合'cloud'时会返回“Forbidden”错误 . 这是我在开发人员指南中找到的示例汇编的python代码 .
import httplib2
import pprint
import sys
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
from oauth2client import client
from httplib2 import Http
SCOPES = ['https://www.googleapis.com/auth/plus.me',
'https://www.googleapis.com/auth/plus.media.upload',
'https://www.googleapis.com/auth/plus.stream.write']
def main(argv):
f = file('Trebor NAO Access-c35352d48d33.p12', 'rb')
key = f.read()
f.close()
credentials = SignedJwtAssertionCredentials('trebor-nao-access-service-659@trebor-nao-access.iam.gserviceaccount.com', key, SCOPES)
http = httplib2.Http()
http = credentials.authorize(http)
service = build(“plusDomains”, “v1”, http=http)
try:
user_id = 'me'
print('Uploading a picture of a box of MiniWheats cereal')
result = service.media().insert(
media_body = 'MiniWheats.jpg',
body = {'displayName': 'MiniWheats.jpg'},
userId = user_id,
collection = 'cloud',
).execute()
print('result = %s' % pprint.pformat(result))
media_id = result.get('id')
print('MediaID of MiniWheats.jpg: %s' % media_id)
if __name__ == '__main__':
main(sys.argv)
非常感谢您给予的任何建议 .
罗伯特迪克西