(SQL Server) HTTP Basic Authentication Test
Demonstrates how to do HTTP basic authentication using Chilkat.
// Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
//
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OASetProperty @http, 'BasicAuth', 1
EXEC sp_OASetProperty @http, 'Login', 'foo'
EXEC sp_OASetProperty @http, 'Password', 'bar'
-- Let's say we want to download a file that is protected by HTTP Basic Authenication..
DECLARE @success int
EXEC sp_OAMethod @http, 'Download', @success OUT, 'https://www.example.com/someDir/document.pdf', 'qa_output/document.pdf'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
RETURN
END
PRINT 'Success.'
EXEC @hr = sp_OADestroy @http
END
GO
|