Sample code for 30+ languages & platforms
PowerBuilder

curl Update Local Manager Secrets

See more CURL Examples

Demonstrates how to initially write secrets to the local manager that will later be used in curl commands. On Windows, this refers to the Windows Credential Manager, and on macOS, it refers to the Apple Keychain.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Secrets
oleobject loo_Json
oleobject loo_Json2

li_Success = 0

// This example will store 3 secrets in the local manager.

// On Windows, this refers to the Windows Credential Manager, and on macOS, it refers to the Apple Keychain.
// These secrets will be used at a later point in time in curl commands,
// as shown in this example:  Using Local Manager Secrets with curl

// Also see: Chilkat v11.5.0 — Secrets Integration
// and also: Chilkat Secrets API

loo_Secrets = create oleobject
li_rc = loo_Secrets.ConnectToNewObject("Chilkat.Secrets")
if li_rc < 0 then
    destroy loo_Secrets
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

loo_Json.UpdateString("appName","sharepoint")
loo_Json.UpdateString("service","oauth2")
loo_Json.UpdateString("username","client_id")

// These are not actual/real values..
li_Success = loo_Secrets.UpdateSecretStr(loo_Json,"4afc67c5-6d3f-4ed0-91c7-5d239c78bff7")
if li_Success = 0 then
    Write-Debug loo_Secrets.LastErrorText
    destroy loo_Secrets
    destroy loo_Json
    return
end if

loo_Json.UpdateString("username","client_secret")
li_Success = loo_Secrets.UpdateSecretStr(loo_Json,"Rlh8Q~~xaP10Dw-goWQDLXrRJfYAFVW1hHauvfhO6")
if li_Success = 0 then
    Write-Debug loo_Secrets.LastErrorText
    destroy loo_Secrets
    destroy loo_Json
    return
end if

loo_Json.UpdateString("username","token_endpoint")
li_Success = loo_Secrets.UpdateSecretStr(loo_Json,"https://login.microsoftonline.com/5f410b89-177f-40b3-9d66-ac519c728025/oauth2/v2.0/token")
if li_Success = 0 then
    Write-Debug loo_Secrets.LastErrorText
    destroy loo_Secrets
    destroy loo_Json
    return
end if

// -----------------------------------------------------------------------------------------------------------
// The above secrets would be accessed like this:
loo_Json2 = create oleobject
li_rc = loo_Json2.ConnectToNewObject("Chilkat.JsonObject")

loo_Json2.EnableSecrets = 1

// Chilkat sees the secret specification string (beginning with "!!") and resolves from the local manager.
loo_Json2.UpdateString("x","!!sharepoint|oauth2|client_id")
Write-Debug "x = " + loo_Json2.StringOf("x")

loo_Json2.UpdateString("y","!!sharepoint|oauth2|client_secret")
Write-Debug "y = " + loo_Json2.StringOf("y")

loo_Json2.UpdateString("z","!!sharepoint|oauth2|token_endpoint")
Write-Debug "z = " + loo_Json2.StringOf("z")

// You can see the values retrieved from the local manager:

// x = 4afc67c5-6d3f-4ed0-91c7-5d239c78bff7
// y = Rlh8Q~xaP10Dw-goWQDLXrRJfYAFVW1hHauvfhO6
// z = https://login.microsoftonline.com/5f410b89-177f-40b3-9d66-ac519c728025/oauth2/v2.0/token


destroy loo_Secrets
destroy loo_Json
destroy loo_Json2