Hi,

Is this correct one?

basic_auth = ""
    if (parameter[:password])
        password1 = parameter[:password].to_s
        basic_auth = Base64.encode64("admin"+":"+password1)
    end

        resp = RestClient.put uri, str.strip!.to_s, :content_type =>
'text/xml', :Authorization => basic_auth

Will this pass user and password values to RestClient (req.basic_auth(user,
password)?

Thanks,
Kavita

On Mon, Feb 14, 2011 at 4:56 AM, Brandon Casci <[email protected]>wrote:

>
> https://github.com/adamwiggins/rest-client
>
> One of the first examples shows the credentials in the URL. Helpful?
>
> Sent from my iPhone
>
> On Feb 13, 2011, at 5:56 PM, "kavitha.k kavi" <[email protected]> wrote:
>
> Hi,
>
> I have heard a lot about Heroku and his work on Ruby on rails. I have
> started working on ruby newly. I need to implement basic authorization
> (https). I have used Heroku's implementation for http GET, PUT, POST and
> DELETE methods. I need to pass username and password so that RestClient
> does  basic authorization and returns the result.
> Can you please help me how to pass username and password (for basic
> authentication) as optional parameters to RestClient.
> Suppose,
>
> - > If the restclient module is defined as follows,
>     def self.put(url, payload, headers={})
>          Request.execute(:method => :put, :url => url, :payload => payload,
> :headers => headers)
>     end
>
> - > username, password, headers , methods(GET, PUT, POST, DELETE) are
> initialised as follows,
>     def initialize(args)
>      @method = args[:method] or raise ArgumentError, "must pass :method"
>      @url = args[:url] or raise ArgumentError, "must pass :url"
>      @headers = args[:headers] || {}
>      @payload = process_payload(args[:payload])
>      @user = args[:user]
>      @password = args[:password]
>      @timeout = args[:timeout]
>     end
>
> - > Basic authorization is performed internally as,
> def setup_credentials(req)
>     req.basic_auth(user, password) if user
> end
>
> - > Now, I need to pass username and password in the authentication header,
> so that the values are passed to RestClient and basic authorization is
> performed.
> response=RestClient.put uri, resp.to_s, :content_type => 'text/xml' (how
> top pass authentication header from here to RestClient (
> req.basic_auth(user, password) if user )? )
>
> Can you please help me on this?
>
> Regards
> Kavita
>
> --
> You received this message because you are subscribed to the Google Groups
> "Heroku" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Heroku" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to