Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
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
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
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
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
0 Kudos