Developers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
malik
Visitor

Send UserName and Password via AddHeader

Hi,

Can we pass user name and password in AddHeader method of roUrlTransfer? What is the appropriate way of sending soap header with web service request of ASP.NET?

Thanks
Malik
Tags (1)
0 Kudos
3 REPLIES 3

Re: Send UserName and Password via AddHeader

Yup. For basic HTTP authentication, it should look something like this:


http = CreateObject("roUrlTransfer")
http.SetPort(CreateObject("roMessagePort"))
http.SetUrl("http://someurl.com")
http.AddHeader("Content-Type", "application/x-www-form-urlencoded")
ba = CreateObject("roByteArray")
ba.FromAsciiString("username:password")
http.AddHeader("Authorization", "Basic " + ba.ToBase64String())
http.EnableEncodings(true)
return http
--
Float Left Interactive Team
www.floatleftinteractive.com
Tags (1)
0 Kudos
malik
Visitor

Re: Send UserName and Password via AddHeader

Thanks for your reply. I already tried it but when I check header fields in Request Header only five header fields found and the field name "Authorization" is not in the list. If I pass any dummy field name in header it is passed exactly. I found following fields in request header:
1. Content-Type
2. Accept
3. Accept-Encoding
4. Host
5. User-Agent

But the field named "Authorization" is not there. Here is my code:

http = CreateObject("roUrlTransfer")
http.SetUrl("http://someurl.com")
ba = CreateObject("roByteArray")
ba.FromAsciiString("naeem:1234")
http.AddHeader("Content-Type", "application/x-www-form-urlencoded")
http.AddHeader("Authorization", "Basic " + ba.ToBase64String())
http.Http.EnableEncodings(true)


Why "Authorization" field is not add in request header?

Thanks
Malik
Tags (1)
0 Kudos
RokuKevin
Visitor

Re: Send UserName and Password via AddHeader

Your line "http.Http.EnableEncodings(true)" looks out of place.

The http object in this sample is an roUrlTransfer component. There is no additional Http field for this component. Even if you changed to http.EnableEncodings(true), I don't think you are intending to enable gzip encodings.

Note that if you add the "Content-Type" header, you should be doing a POST with the properly formatted application/x-www-form-urlencoded payload.

It looks like you've implemented the Basic Auth, Authorization header correctly otherwise....

--Kevin
Tags (1)
0 Kudos
Community is Being Upgraded!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 19th and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

We're sorry for this disruption — we’re excited to share what’s next!