API问题定位指导-常见问题定位指导:认证不通过

时间:2023-11-01 16:13:46

认证不通过

认证不通过的请求会被API网关拒绝,得到类似如下的返回,返回以APIGW开头的错误码。

比如使用Token认证请求没有带Token,返回如下。
{    "error_msg": "Incorrect  IAM  authentication information: x-auth-token not found",    "error_code": "APIGW.0301",    "request_id": "7775eaa6b4bbe5934e565349bd27c298"}

使用了错误的Token,返回如下。

{    "error_msg": "Incorrect IAM authentication information: decrypt token fail",    "error_code": "APIGW.0301",    "request_id": "0e812a89eee650de8e1f55cdae28b2c9"}

使用了错误的AK,会返回如下错误。

Traceback (most recent call last):  File "/home/user/.local/lib/python3.7/site-packages/huaweicloudsdkcore/http/http_client.py", line 119, in response_hook    resp.raise_for_status()  File "/home/user/.local/lib/python3.7/site-packages/requests/models.py", line 953, in raise_for_status    raise HTTPError(http_error_msg, response=self)requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://iam.myhuaweicloud.com/v3/projects?name=cn-north-4During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "/home/user/.local/lib/python3.7/site-packages/huaweicloudsdkcore/auth/credentials.py", line 93, in process_auth_params    self.project_id = keystone_list_projects(http_client, request)  File "/home/user/.local/lib/python3.7/site-packages/huaweicloudsdkcore/auth/iam_service.py", line 49, in keystone_list_projects    raise e  File "/home/user/.local/lib/python3.7/site-packages/huaweicloudsdkcore/auth/iam_service.py", line 47, in keystone_list_projects    http_response = http_client.do_request_sync(request)  File "/home/user/.local/lib/python3.7/site-packages/huaweicloudsdkcore/http/http_client.py", line 93, in do_request_sync    self.response_error_hook_factory()(response)  File "/home/user/.local/lib/python3.7/site-packages/huaweicloudsdkcore/http/http_client.py", line 130, in response_hook    raise exceptions.ClientRequestException(response_status_code, sdk_error)huaweicloudsdkcore.exceptions.exceptions.ClientRequestException: ClientRequestException - {status_code:401,request_id:3f979354fbec41b3cc0bd28ce7865e20,error_code:APIGW.0301,error_msg:Incorrect IAM authentication information: ak xxxxxx not exist }

使用了错误的SK,返回如下。

huaweicloudsdkcore.exceptions.exceptions.ApiValueError: Failed to get project id, Incorrect IAM authentication information: verify aksk signature fail, canonicalRequest:GET|/v3/projects/|name=cn-north-4|host:iam.myhuaweicloud.com|x-sdk-date:20210902T011700Z||host;x-sdk-date|e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
support.huaweicloud.com/trouble-apitr/apitr_003.html