AutoIt
AutoIt
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 AutoIt Downloads
Local $bSuccess = False
; 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
$oSecrets = ObjCreate("Chilkat.Secrets")
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("appName","sharepoint")
$oJson.UpdateString("service","oauth2")
$oJson.UpdateString("username","client_id")
; These are not actual/real values..
$bSuccess = $oSecrets.UpdateSecretStr($oJson,"4afc67c5-6d3f-4ed0-91c7-5d239c78bff7")
If ($bSuccess = False) Then
ConsoleWrite($oSecrets.LastErrorText & @CRLF)
Exit
EndIf
$oJson.UpdateString("username","client_secret")
$bSuccess = $oSecrets.UpdateSecretStr($oJson,"Rlh8Q~xaP10Dw-goWQDLXrRJfYAFVW1hHauvfhO6")
If ($bSuccess = False) Then
ConsoleWrite($oSecrets.LastErrorText & @CRLF)
Exit
EndIf
$oJson.UpdateString("username","token_endpoint")
$bSuccess = $oSecrets.UpdateSecretStr($oJson,"https://login.microsoftonline.com/5f410b89-177f-40b3-9d66-ac519c728025/oauth2/v2.0/token")
If ($bSuccess = False) Then
ConsoleWrite($oSecrets.LastErrorText & @CRLF)
Exit
EndIf
; -----------------------------------------------------------------------------------------------------------
; The above secrets would be accessed like this:
$oJson2 = ObjCreate("Chilkat.JsonObject")
$oJson2.EnableSecrets = True
; Chilkat sees the secret specification string (beginning with "!!") and resolves from the local manager.
$oJson2.UpdateString("x","!!sharepoint|oauth2|client_id")
ConsoleWrite("x = " & $oJson2.StringOf("x") & @CRLF)
$oJson2.UpdateString("y","!!sharepoint|oauth2|client_secret")
ConsoleWrite("y = " & $oJson2.StringOf("y") & @CRLF)
$oJson2.UpdateString("z","!!sharepoint|oauth2|token_endpoint")
ConsoleWrite("z = " & $oJson2.StringOf("z") & @CRLF)
; 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