admin管理员组

文章数量:1291007

I'm trying to authenticate against the Marketing Cloud SOAP API and am having a nightmare trying to pass the Oauth token in. Code is below. Does anyone have some working code to compare to, I can't see what the problem is here?

public SoapClient CreateSoapClient()
{
    var binding = new BasicHttpBinding
    {
        Security = new BasicHttpSecurity
        {
            Mode = BasicHttpSecurityMode.Transport,
            Transport = new HttpTransportSecurity
            {
                ClientCredentialType = HttpClientCredentialType.None
            }
        },
        MaxBufferSize = int.MaxValue,
        MaxReceivedMessageSize = int.MaxValue
    };

    var endpoint = new EndpointAddress(_soapEndpoint);
    var client = new SoapClient(binding, endpoint);

    AttachWSecurityHeader(client);
    return client;
}

private void AttachWSecurityHeader(SoapClient client)
{
    var token = GetAccessToken();
     
    using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
    {
        var securityHeader = MessageHeader.CreateHeader("fueloauth", ";, token);
        OperationContext.Current.OutgoingMessageHeaders.Add(securityHeader);
    }
}

本文标签: salesforce marketing cloudCorrect key for REST API endpointStack Overflow