login community faq

Hi, I'm trying to log in into Webfaction using the XMLRPC API and Ruby library. Problem is:

1
2
3
require 'xmlrpc/client'
server = XMLRPC::Client.new2("https://api.webfaction.com/")
server.call("login", "user", "password")

While trying this simple example found in the docs, the login call to the server results in:

1

As you can see. I'm using Windows Ruby 1.9.3p0 . Any ideas?

asked Dec 16 '11 at 15:11

Phrozen's gravatar image

Phrozen
5118

Can it be something to do with the API being down? If I go to https://api.webfaction.com/ I got a 404 Not Found error. If I try to login through the Python xmlrpclib I got a Protocol error from /RPC2 same 404 Not found error.

(Dec 16 '11 at 15:15) Phrozen Phrozen's gravatar image

The 404 error is normal, as a browser can not communicate with the API. I can not reproduce the certificate error on my machine. Google Searching for the error seems to suggest this is a problem with Ruby 1.9 and its ability to find the certs. I was unable to locate a solution for windows, nor have access to a windows machine to test.

(Dec 16 '11 at 19:19) johns ♦♦ johns's gravatar image

Do you know something of Python having 404 error too?

(Dec 17 '11 at 21:06) Phrozen Phrozen's gravatar image

No, I was doing my testing with python and it was working. Is it possible to try another OS/machine? Can you post the python code you tested too?

(Dec 17 '11 at 21:23) johns ♦♦ johns's gravatar image

I tried using the code from the webpage:

1
2
3
>>> import xmlrpclib
>>> server = xmlrpclib.ServerProxy('https://api.webfaction.com/')
>>> session_id, account = server.login('widgetsco', 'widgetsrock')

And its working now, maybe the API was offline last time I tried. Anyway, for the Ruby example I'm posting the answer. Thanx for your help.

(Dec 17 '11 at 23:40) Phrozen Phrozen's gravatar image

With Ruby, to bypass the Certificate error you have to somewhat hack into the API of the xmlrpc/client library. And that is because the API does not provide any simple solution to turn off that warning about the certificate, but here is what I found and it works.

1
2
server.instance_variable_get(:@http).instance_variable_set(:@verify_mode, OpenSSL::SSL::VERIFY_NONE)
server.call("login", "user", "password")

The important line being:

1

That turns off the warning and let you connect to the API via xmlrpc library.

Thanx for the help. Even if I could have used Python, I already had the Ruby code, so this hack is faster and better tan porting the script.

Edit: This works on Ruby 1.9.3p0 and pretty sure it works on most 1.9.x versions.

answered Dec 17 '11 at 23:44

Phrozen's gravatar image

Phrozen
5118

edited Dec 17 '11 at 23:45

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×72
×56
×41
×16

Asked: Dec 16 '11 at 15:11

Seen: 1,024 times

Last updated: Dec 17 '11 at 23:45

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited