nategood/httpful

Oauth headers with post()

Budsy opened this issue · 1 comments

Budsy commented

It seems that using addHeader on a post call is not working for me. Can anyone see why?

This fails to execute, (white screen, even when wrapped in try/catch block.):

`

$response = \Httpful\Request::post($url . '?' . $data . '&is_quicksend=true')
->addHeader('Authorization', 'Zoho-oauthtoken ' . $access_token)
->expectsJson()
->sendsJson()
->send();
`

But the following with addHeader stubbed out succeeds in running the post, but of course will not authenticate with Zoho Sign:

`

       $response = \Httpful\Request::post($url . '?' . $data . '&is_quicksend=true') 
                             
	 // ->addHeader('Authorization', 'Zoho-oauthtoken ' .  $access_token) 
	 		 		 
	  ->expectsJson()
	   		   		  
	  ->sendsJson()
	   		   		  
	  ->send();`

The response payload coming back from Zoho Sign API in the latter case is:

{"code":9031,"message":"Ticket invalid","status":"failure"}

The token and header formation are valid when sent through Curl on a command line, so it's not the token or the header formation.

Have you tried removing 'Zoho-oauthtoken' and just leaving the $access_token?

This is a java example, so it may be this.

Java

Using Apache HTTPClient.

DefaultHttpClient httpclient = new DefaultHttpClient();

String url = "http://localhost";

HttpPost httpPost = new HttpPost(url);

httpPost.addHeader("Authorization" , "");

HttpResponse response = httpclient.execute(httpPost);

I hope its of some help, although i have never tried the api with zoho.