Amazon Kinesis Video GetMedia/PutMedia

允我心安 提交于 2020-01-01 18:57:26

问题


I used python 3.6 and I want to post video stream to aws kinesis with API. I used python aws client to create stream and GetDataEndPoint but when I want to post my data with my custom request (PutMedia doesn't include in python client actually), I get an error Unable to determine service/operation name to be authorized.

I've follow the api doc of aws kinesis video media PutMedia and GetMedia.

So I start by getting endpoint with GetDataEndPoint with client method:

response = client.get_data_endpoint(  # aws client method
    StreamName=STREAM_NAME,
    APIName='PUT_MEDIA'
)
end_point = response['DataEndpoint'] # https://s-EXAMPLE.kinesisvideo.eu-west-1.amazonaws.com

and I post my data at this url:

headers = {
    "x-amzn-stream-arn": STREAM_ARN,
    "x-amzn-fragment-timecode-type": "ABSOLUTE",
    "x-amzn-producer-start-timestamp": start_tmstp
}
# Sign header...
response = requests.post(end_point, data=data, headers=headers)  # 403 - Unable to determine service/operation name to be authorized

So I don't understand why I get this error... I've found this troubleshooting on aws doc. But they say we must specify ApiName parameter. What I do...

This error might occur if the endpoint is not properly specified. When you are getting the endpoint, be sure to include the following parameter in the GetDataEndpoint call, depending on the API to be called:

I'm also wondering if the GetMedia method is actually implemented in client as they say here because when I debug this method, client don't call GetDataEndPoint and so make request at https://kinesisvideo.region.amazonaws.com insteed of https://ID_EXAMPLE.kinesisvideo.region.amazonaws.com. So method get error Unable to determine service/operation name to be authorized as explained in troubleshooting


回答1:


The error you're getting is because you're probably providing the endpoint without the "action" that in your case would be putMedia.

Try to append /putMedia to your endpoint and don't forget to specify the "content-type": "application/json" header.

Btw you have also to generate the v4 signatures for your request. You can use a lib or follow this python guide to do it.



来源:https://stackoverflow.com/questions/49713393/amazon-kinesis-video-getmedia-putmedia

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!