PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_BAutoReconnect
oleobject loo_AzSas
string ls_ResponseText
li_Success = 0
loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")
if li_rc < 0 then
destroy loo_Rest
MessageBox("Error","Connecting to COM object failed")
return
end if
li_BTls = 1
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("example.com",443,li_BTls,li_BAutoReconnect)
if li_Success = 0 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
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.
loo_AzSas = create oleobject
li_rc = loo_AzSas.ConnectToNewObject("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.
loo_AzSas.AccessKey = "BASE64_ACCOUNT_ACCESS_KEY"
// Associate the provider with the REST object.
li_Success = loo_Rest.SetAuthAzureSas(loo_AzSas)
if li_Success = 0 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
destroy loo_AzSas
return
end if
ls_ResponseText = loo_Rest.FullRequestNoBody("GET","/mycontainer/myblob.txt")
if loo_Rest.LastMethodSuccess = 0 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
destroy loo_AzSas
return
end if
Write-Debug ls_ResponseText
destroy loo_Rest
destroy loo_AzSas