[Fedora-suds-list] HttpAuthenticated for WSDL open
Matt C
mcauthorn at gmail.com
Tue Dec 22 02:11:52 UTC 2009
Ryan: my setup is similar, and the normal c = Client(url, username =
'foo', password = 'bar') has always worked - could you send a sample
of your code?
-Matt
On Mon, Dec 21, 2009 at 6:03 PM, Ryan Schroeder <ryanitus at gmail.com> wrote:
> Here's the open function for HttpAuthenticated.
>
> class HttpAuthenticated(HttpTransport):
> """
> Provides basic http authentication for servers that don't follow
> the specified challenge / response model. This implementation
> appends the I{Authorization} http header with base64 encoded
> credentials on every http request.
> """
> def open(self, request):
> credentials = self.credentials()
> theurl = request.url
> username = credentials[0]
> password = credentials[1]
> passman = u2.HTTPPasswordMgrWithDefaultRealm()
> passman.add_password(None, theurl, username, password)
> authhandler = u2.HTTPBasicAuthHandler(passman)
> opener = u2.build_opener(authhandler)
> u2.install_opener(opener)
> return HttpTransport.open(self, request)
>
>
>
> On Mon, Dec 21, 2009 at 2:16 PM, Ryan Schroeder <ryanitus at gmail.com> wrote:
>>
>> Hello,
>>
>> I have a server that requires basic HTTP authentication to download the
>> WSDL file. I tried setting the transport to HTTPAuthenticated, but it looks
>> like the Client doesn't apply the options.transport when opening the url.
>>
>> Here's the snippet I'm referring to from client.py:
>>
>> def __init__(self, url, **kwargs):
>> """
>> @param url: The URL for the WSDL.
>> @type url: str
>> @param kwargs: keyword arguments.
>> @see: L{Options}
>> """
>> options = Options()
>> options.transport = HttpAuthenticated()
>> self.options = options
>> options.cache = FileCache(days=1)
>> self.set_options(**kwargs)
>> self.wsdl = Definitions(url, options) <--------------
>> shouldn't this be self.options?
>>
>>
>> I tried making this change, but also ran into the fact that the
>> HttpAuthenticated class does not override the open method using a provided
>> username and password. The basic HttpTransport open method is called
>> instead.
>>
>> Regards,
>>
>> Ryan
>>
>
> _______________________________________________
> fedora-suds-list mailing list
> fedora-suds-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-suds-list
>
More information about the fedora-suds-list
mailing list