Skip to content

Instantly share code, notes, and snippets.

@aimtiaz11
Created July 26, 2022 03:22
Show Gist options
  • Save aimtiaz11/074fcb65d89bcd1ca42eba5f9bf01017 to your computer and use it in GitHub Desktop.
Save aimtiaz11/074fcb65d89bcd1ca42eba5f9bf01017 to your computer and use it in GitHub Desktop.
Get OAuth Token from Anypoint via Connected App (PowerShelll)
$ClientId = "<enter connect app client id>"
$ClientSecret = "<enter connect app client secret>"
## Step 1: Login to get Token
$Props = @{
Uri = "https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token"
Method = "POST"
Headers = @{
'Content-Type' = 'application/json'
}
Body = @{
'grant_type' = 'client_credentials'
'client_id' = $ClientId
'client_secret' = $ClientSecret
} | ConvertTo-Json
}
$Response = Invoke-RestMethod @Props
$Response | ConvertTo-Json
$Token = $Response.access_token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment