Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

'Login Failed' trying to post to API #44

Open
rsliter opened this issue Jan 13, 2016 · 22 comments
Open

'Login Failed' trying to post to API #44

rsliter opened this issue Jan 13, 2016 · 22 comments

Comments

@rsliter
Copy link
Contributor

rsliter commented Jan 13, 2016

I'm making the following request from the docs:

myClient = FuelSDK::Client.new({'client' => { 'id' => CLIENTID, 'secret' => SECRET }})
list = FuelSDK::List.new
list.authStub = myClient
list.props = {"ListName" => "SDKList", "Description" => "SDK Created List"}
results = list.post

The response includes this body:

@body={:fault=>{:faultcode=>"q0:Security", :faultstring=>"Login failed", :faultactor=>"https://webservice.s7.exacttarget.com/Service.asmx"}}

What does this mean? Am I missing some configuration?

@MichaelAllenClark
Copy link
Contributor

If you enabled debug, are you able to see the SOAP payload? It appears to be using your ClientID/ClientSecret to get an access token but then it is failing when making the request to create the list

myClient = FuelSDK::Client.new {'client' => { 'id' => CLIENTID, 'secret' => SECRET }}, true

@rsliter
Copy link
Contributor Author

rsliter commented Jan 13, 2016

yeah, it just says 'Login failed'.. here's a snippet:

<faultcode xmlns:q0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">q0:Security</faultcode>
<faultstring>Login failed</faultstring>
<faultactor>https://webservice.s7.exacttarget.com/Service.asmx</faultactor>

@MichaelAllenClark
Copy link
Contributor

Based on the error, it sounds like the AccessToken isn't making it into the SOAP request that is being made to the MC servers. If the token was blank for some reason, the error would be different. Are you able to see the request payload in the logged data or just the response?

What scenario are you trying to accomplish by using the Fuel SDK? If the scenario is simple like triggering a transactional email or adding a subscriber to a list, you may want to check out some examples of how to use Savon to directly access the Marketing Cloud SOAP API: https://github.com/MichaelAllenClark/exacttarget-soap-ruby/.

@rsliter
Copy link
Contributor Author

rsliter commented Jan 14, 2016

hmm, I'm not sure which part of the request you're looking for-- here's the body:

<env:Body><tns:CreateRequest><tns:Objects><tns:ListName>SDKList</tns:ListName><tns:Description>SDK Created List</tns:Description></tns:Objects></tns:CreateRequest></env:Body>

DEBUG -- : HTTPI POST request to webservice.s*.exacttarget.com (net_http)
INFO -- : SOAP response (status 500)

We're mostly trying to associate subscribers with lists, but when we spoke to our representative (and the docs on exacttarget.com) suggested that this library is the best way to access the data from a Ruby app. Is this not the case?

@MichaelAllenClark
Copy link
Contributor

Is the SOAP header logged with the request? Should be right before: env:Body

The Marketing Cloud SOAP API is standard SOAP service that implements WS-Security for authentication so any client that supports these standards can consume the service. The FuelSDK utilizes the Savon Ruby gem to handle the SOAP requests but also includes additional functionality to help with token management, endpoint determination, and convenience methods. It is possible to access the SOAP services with Ruby(using the Savon gem) without using the FuelSDK as a wrapper. There isn't one option that is better than the other, each has advantages. The FuelSDK is typically quicker to get started with but doesn't provide as much flexibility. Directly accessing the SOAP services introduces less overhead and provides for accessing all options available in the MC SOAP API instead of a limited subset but isn't as well documented.

@rsliter
Copy link
Contributor Author

rsliter commented Jan 14, 2016

yeah, here's the header:

<soap:Header>
<wsa:Action>http://schemas.xmlsoap.org/ws/2004/08/addressing/fault</wsa:Action><wsa:MessageID>urn:uuid:4d27ab22-da90-401e-92e2-30f7ec0ccaa7</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:1c8cc63d-71ea-43b1-acce-7e6211be9d6f</wsa:RelatesTo>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-e2b0b7d3-f2a5-4f26-b585-266d3ec27b77">
<wsu:Created>2016-01-14T15:49:02Z</wsu:Created>
<wsu:Expires>2016-01-14T15:54:02Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>

@MichaelAllenClark
Copy link
Contributor

That looks very unusual, the action is a uri and the "wsa:To" value is not a valid endpoint like it should be. Example of what I would expect:

<wsa:Action>Create</wsa:Action>
<wsa:MessageID>urn:uuid:e133baeb-0ea6-48c4-97a2-a35259159789</wsa:MessageID>
<wsa:To>https://webservice.exacttarget.com/Service.asmx</wsa:To>

Savon leverages Gyoku which is used to translate Ruby Hashes to XML, so a new version of this gem may have broken how it builds out XML when using this older version of Savon. If possible, try reducing your version of the gyoku gem to 1.0.0 if you have a newer version installed.

@rsliter
Copy link
Contributor Author

rsliter commented Jan 14, 2016

yeah, i made sure the version was 1.0.0 and got the same error :(

@chrisatanasian
Copy link

I'm getting the same 'Login Failed' error as @rsliter. Has there been any progress with this? @MichaelAllenClark

@MichaelAllenClark
Copy link
Contributor

Didn't find root cause, switched to using Savon without Fuel SDK. More research is needed to figure out the source of this issue. If debug is enabled in your environment, can you log the SOAP header to confirm you are seeing the same issue with building the XML? Can you provide the output of 'gem list' so I can see what version you are running for all gems?

@chrisatanasian
Copy link

Sure, here is the full SOAP request/response (with the oauth token subbed out):

SOAP request: https://ws-devedition.s7.exacttarget.com/service.asmx
SOAPAction: "Create", Content-Type: text/xml;charset=UTF-8, Content-Length: 1888
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://exacttarget.com/wsdl/partnerAPI" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><oAuth><oAuthToken>*oauth_token_here*</oAuthToken></oAuth><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:Username>*</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">*</wsse:Password></wsse:UsernameToken></wsse:Security></env:Header><env:Body><tns:CreateRequest><tns:Objects><tns:Properties><tns:Property><tns:Name>Properties</tns:Name><tns:Value><tns:Property><tns:Name>Name</tns:Name><tns:Value>SDKDataExtension</tns:Value></tns:Property><tns:Property><tns:Name>Description</tns:Name><tns:Value>SDK Created Data Extension</tns:Value></tns:Property><tns:Property><tns:Name>Fields</tns:Name><tns:Value><tns:Field><tns:Name>OtherField</tns:Name><tns:FieldType>Text</tns:FieldType></tns:Field></tns:Value></tns:Property></tns:Value></tns:Property><tns:Property><tns:Name>@xsi:type</tns:Name><tns:Value>tns:DataExtension</tns:Value></tns:Property><tns:Property><tns:Name>Fields</tns:Name><tns:Value><tns:Field><tns:Name>OtherField</tns:Name><tns:FieldType>Text</tns:FieldType></tns:Field></tns:Value></tns:Property></tns:Properties></tns:Objects></tns:CreateRequest></env:Body></env:Envelope>
HTTPI POST request to ws-devedition.s7.exacttarget.com (net_http)
SOAP response (status 500)
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><soap:Header><wsa:Action>http://schemas.xmlsoap.org/ws/2004/08/addressing/fault</wsa:Action><wsa:MessageID>urn:uuid:55f0f067-f5b0-47fd-97e1-ce19fec3068f</wsa:MessageID><wsa:RelatesTo>urn:uuid:94b387a6-1bee-41c0-ae01-79ca65bc9989</wsa:RelatesTo><wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsse:Security><wsu:Timestamp wsu:Id="Timestamp-ba509088-2fdd-4c49-81e6-e872ffb07f39"><wsu:Created>2016-01-25T20:12:55Z</wsu:Created><wsu:Expires>2016-01-25T20:17:55Z</wsu:Expires></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><soap:Fault><faultcode xmlns:q0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">q0:Security</faultcode><faultstring>Login failed</faultstring><faultactor>https://ws-devedition.s7.exacttarget.com/service.asmx</faultactor></soap:Fault></soap:Body></soap:Envelope>

I also tried creating a brand new Rails app and got the same error. Here's the gem list from it:

=> ~/projects/TestFuelSDK/ bundle exec gem list

*** LOCAL GEMS ***

actionmailer (4.2.5)
actionpack (4.2.5)
actionview (4.2.5)
activejob (4.2.5)
activemodel (4.2.5)
activerecord (4.2.5)
activesupport (4.2.5)
akami (1.2.2)
arel (6.0.3)
binding_of_caller (0.7.2)
builder (3.2.2)
bundler (1.11.2)
byebug (8.2.1)
coderay (1.1.0)
coffee-rails (4.1.1)
coffee-script (2.4.1)
coffee-script-source (1.10.0)
concurrent-ruby (1.0.0)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.6.0)
fuelsdk (0.1.11)
globalid (0.3.6)
gyoku (1.0.0)
httpi (2.0.2)
i18n (0.7.0)
jbuilder (2.4.0)
jquery-rails (4.1.0)
json (1.8.3)
jwt (1.5.1)
loofah (2.0.3)
mail (2.6.3)
method_source (0.8.2)
mime-types (2.99)
mini_portile2 (2.0.0)
minitest (5.8.4)
multi_json (1.11.2)
nokogiri (1.6.7.2)
nori (2.1.0)
pry (0.10.3)
rack (1.6.4)
rack-test (0.6.3)
rails (4.2.5)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.7)
rails-html-sanitizer (1.0.2)
railties (4.2.5)
rake (10.5.0)
rdoc (4.2.1)
sass (3.4.21)
sass-rails (5.0.4)
savon (2.2.0)
sdoc (0.4.1)
slop (3.6.0)
spring (1.6.2)
sprockets (3.5.2)
sprockets-rails (3.0.0)
sqlite3 (1.3.11)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.2)
turbolinks (2.5.3)
tzinfo (1.2.2)
uglifier (2.7.2)
wasabi (3.1.0)
web-console (2.2.1)

@MichaelAllenClark
Copy link
Contributor

That makes a lot more sense now that I can see the request and the response header. The request SOAP header appears to be correct. I am not sure where the endpoint https://ws-devedition.s7.exacttarget.com/Service.asmx is coming from though. Are you trying to access a production support (mc.test.exacttarget.com) account?

@chrisatanasian
Copy link

Hmm I am trying to access mc.s7.exacttarget.com. I'm not sure if that is production support or not.

@MichaelAllenClark
Copy link
Contributor

I am starting to think there is something odd with your account, not the code. Are you able to create a new Server-To-Server app using https://appcenter.s1.marketingcloudapps.com/ to get a new set of App Keys? If so, do those new keys exhibit the same issue?

@chrisatanasian
Copy link

I created a new app and got a new set of App Keys and am still having the same issue. FuelSDK should handle the refresh and auth tokens, right (once the client_id and client_secret are passed)?

@MichaelAllenClark
Copy link
Contributor

That is correct, the FuelSDK should handle obtaining and refreshing the necessary tokens. Based on the endpoint that is showing up in your requests: https://ws-devedition.s7.exacttarget.com/Service.asmx, you may be using a free developer account that was provided for training at Connections or Dreamforce. I believe these accounts were only active for those events and a short time after but shouldn't be available for use any longer. If you are attempting to use a standard Marketing Cloud account and still receiving the login failed error, please contact Marketing Cloud Global Support.

@sabrinaluo
Copy link

hi I have the same issue, any ideas about how to fix this? thank you

@amagar088
Copy link
Contributor

Hi @sabrinaluo , can you please share some more details, like debug log ,
Additionally, can you try to login with the credentials you have to Marketing Cloud UI.

@sabrinaluo
Copy link

Hi, I got the 'Login Failed' error sometimes, with the same credentials, the clientId and clientSecret were created in APP center. It seems not stable. we didn't change any of our codebase, and didn't change any of the deployment. It works for most of the time, but we still find few records with 2 types of error for different business unit. I have double checked that the credentials are correct, we did nothing later on, it magically worked again.
1.

{
    "faultstring": "Login Failed",
    "faultCode": "q0:Security",
    "errorPropagatedFrom": "SOAP Fault"
}
{
    "faultstring": "Login Failed",
    "faultCode": "q0:Security",
    "errorPropagatedFrom": "SOAP Fault"
}

@rsliter
Copy link
Contributor Author

rsliter commented Aug 11, 2016

FWIW I could never get it working :( I ended up writing a wrapper using the Savon ruby gem.

@amagar088
Copy link
Contributor

can u take a fresh pull from this repo and try. If you face an error, can you provide me some detail log

@nonameduck
Copy link

Anything ever come of this? I'm getting the same response via Postman when trying to start an automation via SOAP.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants