开发者社区> 问答> 正文

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

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

展开
收起
小天使爱美 2020-03-27 18:37:45 1193 0
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
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载