API authentication issue | Community
Skip to main content
Level 4
August 13, 2020
Solved

API authentication issue

  • August 13, 2020
  • 2 replies
  • 3128 views

Hi folks, 

 

i am writing a javascript code to get the access token from an API using grant_type = password but i am getting the below error : 

 

Results = {"reason":"Unknown grant_type"}

HTTP header 'WWW-Authenticate' used for proxy authentication not found.

 

script : 

 

var http = new HttpClientRequest("https://api.trustpilot.com/v1/oauth/oauth-business-users-for-applications/accesstoken")

var buffer = new MemoryBuffer()
buffer.fromString("hrIrJQO0rKQdWSf" + ':' + "AK4ceo", "iso-8859-1");
http.header["Content-Type"] = "application/x-www-form-urlencoded";
http.header["Authorization"] = "Basic " + buffer.toBase64();
http.header["grant_type"] = "password";
http.header["username"] = "abc.com;
http.header["password"] = "PaneL321!@";
http.body = "grant_type=password&username=abc.com&password=PanesddL321!@";
http.method = "GET"

http.execute()

var result = http.response.body.toString();
logInfo("Results = " + result)

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Manoj_Kumar

Hello @ramaswami 

First change the http.method to POST then

try removing these 3 headers from your request.

 

 

http.header["grant_type"] = "password"; http.header["username"] = "abc.com; http.header["password"] = "PaneL321!@";

 

 

According to the official trust pilot documentation, It is only accepting the authorization header,content Type and the Form data.

 

Also, you can refer to this documentation for additional troubleshooting: https://developers.trustpilot.com/authentication

 

Let me know if that works.

Thanks,

 

2 replies

Level 3
August 13, 2020

Make sure there is no firewall blocking 

Manoj_Kumar
Community Advisor
Manoj_KumarCommunity AdvisorAccepted solution
Community Advisor
August 14, 2020

Hello @ramaswami 

First change the http.method to POST then

try removing these 3 headers from your request.

 

 

http.header["grant_type"] = "password"; http.header["username"] = "abc.com; http.header["password"] = "PaneL321!@";

 

 

According to the official trust pilot documentation, It is only accepting the authorization header,content Type and the Form data.

 

Also, you can refer to this documentation for additional troubleshooting: https://developers.trustpilot.com/authentication

 

Let me know if that works.

Thanks,

 

Manoj  | https://themartech.pro