Python 3.x 由于调用者没有权限,从S3到GCS的Google StorageTransfer作业失败
我尝试使用API将文件从AmazonS3传输到Google云存储。我在GCP控制台上成功地执行了此操作,但当我使用服务帐户凭据编写Python脚本时,在请求时得到了Python 3.x 由于调用者没有权限,从S3到GCS的Google StorageTransfer作业失败,python-3.x,google-cloud-platform,google-cloud-storage,google-client,Python 3.x,Google Cloud Platform,Google Cloud Storage,Google Client,我尝试使用API将文件从AmazonS3传输到Google云存储。我在GCP控制台上成功地执行了此操作,但当我使用服务帐户凭据编写Python脚本时,在请求时得到了HttpError 403https://storagetransfer.googleapis.com/v1/transferJobs?alt=json 返回“呼叫方没有权限 另外,我的服务帐户已经是存储对象管理员 我正在使用的脚本 import google.auth import google_auth_httplib2 impo
HttpError 403https://storagetransfer.googleapis.com/v1/transferJobs?alt=json 返回“呼叫方没有权限
另外,我的服务帐户已经是存储对象管理员
我正在使用的脚本
import google.auth
import google_auth_httplib2
import google.oauth2.service_account
from googleapiclient.discovery import build
_DEFAULT_SCOPES = ('https://www.googleapis.com/auth/cloud-platform',)
credentials = (
google.oauth2.service_account.Credentials.from_service_account_file(
key_path, scopes=_DEFAULT_SCOPES)
)
http = httplib2.Http()
http_authorized = google_auth_httplib2.AuthorizedHttp(
credentials, http=http)
conn = build('storagetransfer', 'v1', http=http_authorized, cache_discovery=False)
now = datetime.datetime.utcnow()
project_id='projectid'
transfer_spec = {
'awsS3DataSource': {
'bucketName': 's3_bucket',
'awsAccessKey': {
'accessKeyId': 'key',
'secretAccessKey': 'secret',
}
},
'gcsDataSink': {
'bucketName': 'bucket',
},
'objectConditions': {'includePrefixes': ['PREFIX']},
'transferOptions': {'overwriteObjectsAlreadyExistingInSink': True},
}
transfer_job = {
'status': 'ENABLED',
'projectId': project_id,
'transferSpec': transfer_spec,
'schedule': {
'scheduleStartDate': {
'day': now.day,
'month': now.month,
'year': now.year,
},
'scheduleEndDate': {
'day': now.day,
'month': now.month,
'year': now.year,
}
}
}
job = conn.transferJobs().create(body=transfer_job).execute()
有人知道少了什么吗
文档:根据文档,您需要分配以下权限所有者/editor/storagetransfer.admin/storagetransfer.user之一。还有一个python脚本示例可能有助于将数据从S3传输到GCS。问题已解决?您能解决此问题吗?不,它还没有解决Yet遇到相同的问题-您曾经解决过吗解决这个问题?