开发者社区 问答 正文

我使用函数的context参数中的access key id/secret等信息访问其他云资源,为什

我使用函数的context参数中的access key id/secret等信息访问其他云资源,为什么身份验证失败,收到 The AccessKeyID does not exist 的错误?

展开
收起
小天使爱美 2020-03-27 18:37:45 1228 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • 函数 context 中提供了访问云资源的临时密钥,包含 access key id,access key secret,security token 3元组。请不要遗漏了security token。下图是在 python 函数中访问 OSS 代码示例。

    import json import oss2 def my_handler(event, context): evt = json.loads(event) creds = context.credentials # 身份验证时,请不要遗漏了 security_token! # Do not miss the "security_token" for the authentication! auth = oss2.StsAuth(creds.access_key_id, creds.access_key_secret, creds.security_token) bucket = oss2.Bucket(auth, evt['endpoint'], evt['bucket']) bucket.put_object(evt['objectName'], evt['message']) return 'success'

    2020-03-27 18:43:26 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
问答地址:
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等