尝试使用 SDK 访问阿里云中配置的 EDAS 应用。下面的代码返回错误代码 401(“无效用户”)。我已经检查了 EDAS 设置,它只是为我自己的主帐户设置的。感谢是否有人可以就此分享一些指导。
- - - 代码 - - - - -
# -*- coding: utf-8 -*-
import sys from aliyunsdkcore.client
import AcsClient from aliyunsdkedas.request.v20170801
import QueryApplicationStatusRequest
import uuid from aliyunsdkcore.profile
import region_provider from aliyunsdkcore.http
import method_type as MT from aliyunsdkcore.http
import format_type as FT
try:
reload(sys)
sys.setdefaultencoding('utf8')
except NameError:
pass except Exception as err:
raise err
REGION = "ap-southeast-1"
PRODUCT_NAME = "Edas"
ENDPOINT = "edas.ap-southeast-1.aliyuncs.com"
ACCESS_KEY_ID = "Primary account key ID"
ACCESS_KEY_SECRET = "Primary account security key"
region_provider.add_endpoint(PRODUCT_NAME, REGION, ENDPOINT)
acs_client = AcsClient(ACCESS_KEY_ID, ACCESS_KEY_SECRET, REGION)
def query_application():
qappreq = QueryApplicationStatusRequest.QueryApplicationStatusRequest()
qappreq.set_AppId('457290d6-9426-49c8-835c-4133f6a4d268')
qappresponse = acs_client.do_action_with_exception(qappreq)
return qappresponse
if __name__ == '__main__':
print(query_application())
在运行上面的代码时,我得到了这个输出,
{"Code":401}