POST 获得 Trustpilot API 访问令牌挑战

POST to get Trustpilot API access token challenges

我有以下脚本似乎没问题,但它returns以下

{"reason":"Unknown grant_type"}

http://apps.trustpilot.com/authentication

我使用了 public 函数之一来生成 Base 64 编码,它似乎按照下面提到的 response.write 工作。从参考的文档 link 中,您看到我可能遗漏了什么吗?我确信我拥有正确的密钥、秘密、用户名和密码。我是否正确处理了授权类型的负载?

这是 VBScript 代码:

<%
Dim consumerKey,consumerSecret,EndPoint,Payload,myCstr,myAuth
consumerKey = "XXXX"
consumerSecret = "YYYY"
EndPoint = "https://api.trustpilot.com/v1/oauth/oauth-business-users-for-applications/accesstoken"
Payload = "grant_type=password&username=aaa@bbb.com&password=pass28"
myCstr = Base64_Encode(consumerKey & ":" & consumerSecret)
myAuth = "Basic "&myCstr
response.write(Endpoint & "?" & Payload & "<br>")    
response.write(myAuth)
Dim xmlhttp 
Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST",EndPoint & "?" & Payload,false    
'this code not sure if I need - xmlhttp.setRequestHeader "User-Agent","HTTP/1.1"
xmlhttp.setRequestHeader "Authorization", myAuth
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send
Response.write xmlhttp.responseText
%>

每个评论(谢谢,我是新手),这是我如何让它工作的:

我最初错过了 xmlhttp.responsetext 并且在那之前根本没有得到任何回应,我想我还是会在这一点上分享,以防其他人 运行 遇到像我花了几个小时弄清楚的问题!

<%
Dim consumerKey,consumerSecret,myCstr    
consumerKey = "XXXX"
consumerSecret = "YYYY"
EndPoint = "https://api.trustpilot.com/v1/oauth/oauth-business-users-for-applications/accesstoken"
Payload = "grant_type=password&username=aaa@bbb.com&password=pass28"
myCstr = Base64_Encode(consumerKey & ":" & consumerSecret)
myAuth = "Basic "&myCstr
response.write(Endpoint & "?" & Payload & "<br>")    
response.write(myAuth)
Dim xmlhttp 
Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST",EndPoint,false    
'xmlhttp.setRequestHeader "User-Agent","HTTP/1.1"
xmlhttp.setRequestHeader "Authorization", myAuth
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send(Payload)
Response.write xmlhttp.responseText
%>