[squeak-dev] https & woocommerce; basicAuth etc?
tim Rowledge
tim at rowledge.org
Mon Oct 1 21:45:48 UTC 2018
Yay! Winner!
> On 2018-10-01, at 2:30 PM, Levente Uzonyi <leves at caesar.elte.hu> wrote:
>
> On Mon, 1 Oct 2018, tim Rowledge wrote:
>
>>
>> I suspect I can make up a way to do a more direct use-auth-first-time approach that might be better when you know it has to have it. After my frog pills...
>
> Yes you can. You just have to add the Authorization header yourself. Adding basic auth manually to the example in help would look something like this:
>
> | client username password response |
> client := WebClient new.
> username := 'Tim'.
> password := 'secret'.
> response := client httpGet: 'http://www.squeak.org/protected' do: [ :request |
> request headerAt: 'Authorization' put: 'Basic ', (username, ':', password) base64Encoded ].
> response content. "Prefetch response body before closing the client."
> client close. "Do not let WebClient instances leak external semaphores."
> ^response
I saw the httpGet:do: but hadn't a clue how to assemble the header bit. Thank you!
tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Law of Logical Argument: Anything is possible if you don't know what you are talking about.
More information about the Squeak-dev
mailing list
|