Duplication of host when given absolute path : "the scheme http does not accept registry part"

858 views
Skip to first unread message

Dan Neil

unread,
Aug 6, 2012, 5:45:27 AM8/6/12
to oauth...@googlegroups.com
Hi all,

I've been using this oauth plugin (0.4.6) to handle requests to Picasa, and have just upgraded my gem sources.  However, the code broke with the following error:


URI::InvalidURIError: the scheme http does not accept registry part: picasaweb.google.com:80picasaweb.google.com (or bad hostname?)

The code seems to request e.g., "http://picasaweb.google.com:80picasaweb.google.com/data/feed/api/user/default" instead of "http://picasaweb.google.com:80/data/feed/api/user/default"

When given an absolute path, line 337 in consumer.rb reads the following and generates the url:
path = uri.path + path if uri.path
Changing it to an unless condition fixes my problem:
path = uri.path + path unless uri.path

Am I misusing the token, or should line 337 be changed to the "unless" condition?  Thanks.

-Danny

Dan Neil

unread,
Aug 10, 2012, 5:26:03 AM8/10/12
to oauth...@googlegroups.com
For anyone else who has this problem, it is a mistake in how we're using this.  When you initialize your token, pass in the site (with the http/https at the beginning):
      consumer = OAuth::Consumer.new(app_id, app_secret,
        { :site => "https://" + Picasa.host,
          :scheme => :header
        })
then when you make a request, use only relative urls:
    path = Picasa.path(options)
    puts "Contacting: #{path}"     # ==> Contacting: /data/feed/api/user/default?max-results=500&start-index=1&kind=photo&thumbsize
    response = token.request(:get, path)

And it should all work great.
-Danny
Reply all
Reply to author
Forward
0 new messages