What should be binding in WCF Client for calling SOAP web service with OAuth Authentication

Patel, Manoj (IST) 1 Reputation point
2021-02-03T00:11:41.347+00:00

Hello,

I am having WCF client which consumes SOAP based web service which has OAuth authentication. My WCF service gets consumed by some other service but my issue is about authentication when it consumes web service.

My WCF client, consumes web service using proxy generated classes approach. I am able to get Bearer token for OAuth authentication and pass it to request http header as well however, proxy generated class expects binding configuration as well.

var client = new ExchangeServicePortTypeClient("**EndPointConfigurationName**", "WebServiceURL")

I have tried basicHttpBinding, customBinding (AuthenticationMode="IssuedToken/IssuedTokenForCertificate/IssuedTokenOverTransport"), wsHttpBinding (security mode Message & ClientCredentialType 'IssuedToken" but no luck.
I am assuming due to wrong not supported binding configuration authorization bearer token I am sending is not getting accounted.

I am able to consume this web service from console application successfully where I am not using proxy generated classes approach. So I just required to pass authorization bearer token in header and no binding information.

request.Headers.Add("Authorization", "Bearer " + accessToken);

Can someone please suggest what binding information I should add in my WCF client which can support OAuth authentication ?

Thanks,

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,988 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.