Jump to content









Photo

Unsupported grant type http request OAuht2


  • Please log in to reply
4 replies to this topic

#1 BaptisteH

BaptisteH

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 09 July 2018 - 01:44 PM

Hi,

 

I hope you are all doing well!

 

I currently try to develop a Listener which call a private webservice on Salesforce.

I use Basichttp request and I need to POST on https://[...]/oauth2/token to get my token.

 

def http = new BasicHttp()
def postHeader = ['Content-Type': 'application/x-www-form-urlencoded']
def postBody = [
		grant_type: 'password',
		client_id: consumer_key,
		client_secret: consumer_secret,
		username: auth_username,
		password: auth_password
		]
http.headers = postHeader;
http.verb ="POST";
http.payload =  JsonOutput.toJson(postBody);
http.url =sf_login_domain;
def res = http.send();

The SDK engine response is :

"  Details: 'Request error: 400 - {"error":"unsupported_grant_type","error_description":"grant type not supported"}  '"

 

The grand-type shall be password but it seems that it doesn't work.

 

Did you ever ecounter this error?

 

Thank you,



#2 Yoleon

Yoleon

    Sugar Master

  • Members
  • PipPipPip
  • 50 posts

Posted 10 July 2018 - 06:53 AM

Hi BaptisteH,

 

The response that you have received it's from the Saleforce service. We don't have any similar error to "unsuported_grant_type", please revise your code/oauth and tell us.

 

Regards,

 

Carriots Staff



#3 BaptisteH

BaptisteH

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 11 July 2018 - 02:57 PM

Hi Yoleon,

 

It seems that the problem comes from the fact that the header and/or the body are wrong setted.

Maybe i didn't understand the difference between BasicHttp.payload and BasicHttp.params or how to set them.

 

Regards,

 

Baptiste Hector



#4 Yoleon

Yoleon

    Sugar Master

  • Members
  • PipPipPip
  • 50 posts

Posted 12 July 2018 - 09:44 AM

Hi Baptiste,

 

I have been looking at the documentation of Salesforce for oauth2 and it seems like you need to send pairs of values, so you need to construct a map of elements and try to send it in the BasicHttp.params.

 

Here I let you the Saleforce oauth2 and the Carriots SDK documentation.

 

Regards,

 

Carriots Staff



#5 BaptisteH

BaptisteH

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 13 July 2018 - 09:00 AM

Hi,

 

Ok, it works now. I had to set an URL in BasicHttp.payload and values in BasicHttp.params.

 

Thank you very much.

 

Regards,

 

Baptiste Hector






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users