Tcl
Tcl
Windows Credentials Manager / Apple Keychain - Get a JSON Secret
See more Secrets Examples
On Windows, fetches the content of a JSON secret from the Windows Credentials Manager.On MacOS or iOS, fetches from the Apple Keychain.
Note: This example requires Chilkat v10.1.0 or later.
Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set secrets [new_CkSecrets]
# On Windows, this is the Windows Credentials Manager
# On MacOS/iOS, it is the Apple Keychain
CkSecrets_put_Location $secrets "local_manager"
# Specify the secret to be fetched.
set json [new_CkJsonObject]
CkJsonObject_UpdateString $json "appName" "MyApp"
CkJsonObject_UpdateString $json "service" "OAuth2"
CkJsonObject_UpdateString $json "domain" "onedrive"
CkJsonObject_UpdateString $json "username" "matt"
# Get the secret.
set jsonSecret [new_CkJsonObject]
set success [CkSecrets_GetSecretJson $secrets $json $jsonSecret]
if {$success == 0} then {
puts [CkSecrets_lastErrorText $secrets]
delete_CkSecrets $secrets
delete_CkJsonObject $json
delete_CkJsonObject $jsonSecret
exit
}
CkJsonObject_put_EmitCompact $jsonSecret 0
puts [CkJsonObject_emit $jsonSecret]
puts "Success."
delete_CkSecrets $secrets
delete_CkJsonObject $json
delete_CkJsonObject $jsonSecret