We have a WCF service in .NET 4.7.2. This WCF has been configured for "oAuth0"(Not Aure but a third party provider). We are able to call a method on this service using PostMan successfully. What we did is we generated a token on side and pass this token while hitting end point using postman. This way we have ensured our configuration for oAuth0 is working fine.
Now we are trying to call the endpoint in WCF, using a console client but its not working for us. We have generated a proxy class and using the same to call end point on WCF.
// Following is code sample I have pickeup from internet only.
using (Service1Client client = new Service1Client())
{
token = "Bearer " + token; // assume we have value for token here
using (new System.ServiceModel.OperationContextScope(client.InnerChannel))
{
var head = System.ServiceModel.Channels.MessageHeader.CreateHeader("Authorization", "http://localhost:53515/Service1.svc", token);
OperationContext.Current.OutgoingMessageHeaders.Add(head);
}
string response = client.GetDataWoToken(12345);
if (response != null)
{
System.Console.WriteLine("respone from WCF Service was ::->> " + response);
}
System.Console.ReadLine();
}
And this is how I am tryin to access the header in WCF Service
string authorizationHeader = WebOperationContext.Current.IncomingRequest.Headers["Authorization"];
On debugging, its clear that "MessageHeader" is not the right option.
Any pointers would be useful.
Bests regards & thanks in Adance
S