VBScript
VBScript
Configure Azure SAS Authentication for REST
See more REST Examples
Demonstrates Rest.SetAuthAzureSas, which associates an AuthAzureSAS provider so requests are authorized with an Azure Shared Access Signature token.
Background. A SAS token grants time-limited, permission-scoped access to Azure Storage resources without exposing the account key on the wire. Use SAS authorization when a query-token approach is preferred over Shared Key headers.
Chilkat VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
set rest = CreateObject("Chilkat.Rest")
bTls = 1
bAutoReconnect = 1
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
If (success = 0) Then
outFile.WriteLine(rest.LastErrorText)
WScript.Quit
End If
' Configure Azure Shared Access Signature (SAS) authentication. Provide the account access key
' and the SAS token query parameters; Chilkat adds the SAS token to each request.
set azSas = CreateObject("Chilkat.AuthAzureSAS")
' Normally you would not hard-code secrets in source. You should instead obtain them from an
' interactive prompt, environment variable, or a secrets vault.
azSas.AccessKey = "BASE64_ACCOUNT_ACCESS_KEY"
' Associate the provider with the REST object.
success = rest.SetAuthAzureSas(azSas)
If (success = 0) Then
outFile.WriteLine(rest.LastErrorText)
WScript.Quit
End If
responseText = rest.FullRequestNoBody("GET","/mycontainer/myblob.txt")
If (rest.LastMethodSuccess = 0) Then
outFile.WriteLine(rest.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(responseText)
outFile.Close