function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SvenSven 

Basic Authentication - httprequest

Hi,

 

I was wondering if we could use something different then basic authentication.

 

If i do a post to an url using C# with this example

 

String usern = "test"; String passw = "test"; myReq.Credentials = new NetworkCredential(usern, passw); myReq.PreAuthenticate = true; myReq.Method = "POST";

 then the post works fine.

 

If i use the same url but do the authentication using the examples found in the docs then i get an access denied.

 

Apex code

 

 

String username = 'test'; String password = 'test'; Blob headerValue = Blob.valueOf(username+':'+password); String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader);

 

 So i think the server does not use Basic authentication (i don't have access to the server).

 

What is the difference between the 2 methods and can i do authentication like the C# example in Salesforce?

 

Thanks for your help

 


 

sdavidow9sdavidow9
Did you ever resolve this issue?
PamSalesforcePamSalesforce

Hi,

 

Were you able to resolve this issue?

SvenSven

No not really,

 

i resolved it by asking the client to set his webserver to allow basic authentication.

 

then it works fine

 

Sven 

sdavidow9sdavidow9

We are still (sorta) dealing with the issue, but it came down to issues on the SAP side with their Web Dispatcher not sending the entire header (or something like that).  We also found this post, not sure if it would have made a difference as there was problems beyond that:

http://www.coderanch.com/t/441159/Web-Services/java/provide-basic-authetication-from-SOAP

 

We are still looking to get certificates working.