【发布时间】:2020-04-17 14:10:07
【问题描述】:
授权:基本 {client_id}:{client_secret}
整个 {client_id}:{client_secret} 字符串必须经过 Base64 编码(如果您将其作为 --user 凭据传递,curl 将自动对字符串进行 Base64 编码;在其他语言中,您需要处理 Base64-自己编码)。
这是否意味着我单独对 id 和 secret 进行编码,还是对整个内容进行编码?我仍然不确定我做错了什么。这是我此时的代码:
id_key = b64encode('myid12345qwerty'.encode()).decode("utf-8")
secret_key = b64encode('mysecret12345qwerty67890'.encode()).decode("utf-8")
creds = '{'+id_key+':'+secret_key+'}'
headers = {'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic ' + creds}
r = requests.post('https://oauth.brightcove.com/v4/access_token?grant_type=client_credentials', headers = headers)
print(r.status_code)
print(r.text)
这给出了错误,表明它没有获取 client_id 参数。
{"error":"invalid_client","error_description":"The "client_id" parameter is missing, does not name a client registration that is applicable for the requested call, or is not properly authenticated."}
感谢您的指点。
【问题讨论】:
标签: python api brightcove