softlayer / softlayer-ruby

http://softlayer.github.io/softlayer-ruby/
MIT License
54 stars 35 forks source link

SoftLayer::User_Customer.getPortalLoginToken is unusable without API key #72

Closed joshforisha closed 7 years ago

joshforisha commented 9 years ago

The getPortalLoginToken method should not require a username or API key in order to be called for authentication, but SoftLayer::Client requires the use of both.

See http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer/getPortalLoginToken

SLsthompson commented 9 years ago

Call getPortalLoginToken using a SoftLayer:Service directly:

user_customer = SoftLayer::Service.new("SoftLayer_User_Customer") result = user_customer.getPortalLoginToken("your-username", "your-password")

joshforisha commented 9 years ago

Oh, I didn't even think to try that. Thanks!

However, I still get "A SoftLayer Client requires a username" from the Service.new call.

SLsthompson commented 9 years ago

Which version of the softlayer_api gem are you using?

joshforisha commented 9 years ago

3.0.0

SLsthompson commented 9 years ago

Whoops. Forgot I had a .softlayer config file. It's providing the username and API key for me. Ok. Let me re-examine.

SLsthompson commented 9 years ago

OK. I can give you workaround, but I'll have to think about the problem in more detail to get a real fix. You might try this:

mock_client = SoftLayer::Client.new(username: "fake", api_key: "fake") def mock_client.authentication_headers {} end

service = SoftLayer::Service.new("SoftLayer_User_Customer", client: mock_client) result = service.getPortalLoginToken("your_username", "your_password").inspect

real_client = SoftLayer::Client.new(username: result["userId"].to_s, api_key: result["hash"]) puts real_client["Account"].getObject

joshforisha commented 9 years ago

Thanks, that will work for now.

renier commented 8 years ago

Pull request #106 is related

renier commented 7 years ago

This has been fixed in #106 .