Created
December 8, 2023 09:28
-
-
Save mjendza/102bf99a1721710faf9a7690b0cec8c2 to your computer and use it in GitHub Desktop.
ClientCredential-1PasswordCLI-sample.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#LINK 1Password secrets to the environment variables | |
$ENV:FL_SP_CLIENT_ID = "op://Factorlabs/Factorlabs Service Principal for 1password demo/username" | |
$ENV:FL_SP_CLIENT_SECRET = "op://Factorlabs/Factorlabs Service Principal for 1password demo/password" | |
$client_id = $env:FL_SP_CLIENT_ID | |
$client_secret = $env:FL_SP_CLIENT_SECRET | |
$tenant_id = "6790fadf-1111-4f73-8f65-844675b9a99a" | |
$resource = [uri]::EscapeDataString("https://graph.microsoft.com/.default") | |
$tokenUrl = "https://login.microsoftonline.com/$tenant_id/oauth2/token" | |
$Body = "grant_type=client_credentials&client_id=$client_id&client_secret=$client_secret&scope=$resource" | |
Write-Output $Body | |
$Headers = @{ | |
'Content-Type' = 'application/x-www-form-urlencoded' | |
} | |
curl $tokenUrl -H $Headers -body $Body -Method 'POST' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment