# Copy this code and save it to a file called authentication_example.ps1
# Replace placeholders below and run the command: .\authentication_example.ps1

$ClientId = "REPLACE-ME-WITH-CLIENT-ID"
$ClientSecret = "REPLACE-ME-WITH-CLIENT-SECRET"
$OcpApimSubscriptionKey = "REPLACE-ME-WITH-SUBSCRIPTION-KEY"
$Scope = "REPLACE-ME-WITH-SCOPE"
$OrganizationNumber = "REPLACE-ME-WITH-ORGANIZATION-NUMBER" 
# Request new Access token. No need for changing anything below
echo "Requesting access token from identity provider"
$access_token = Invoke-RestMethod -Uri https://id.talenom.com/api/b2b/oauth2/v1.0/token  -ContentType application/x-www-form-urlencoded -Method POST `
  -Body "grant_type=client_credentials&client_id=$ClientId&client_secret=$ClientSecret&scope=$Scope" -Verbose | Select-Object -Expand access_token 
  echo "This is your access token: "  $access_token
  pause "Move on to next phase to make the actual request to the API"
# ApiUrl is the actual url to make the GET request. In this example we will call organization-api and get basic organization information for the organization assigned in the parameters. 
  $ApiUrl = 'https://apim.talenom.com/organization/v1/organization-info/'+ $OrganizationNumber
  $Headers = @{
    'Authorization' = "Bearer " + $access_token
    'Content-Type' = 'application/json'
    'Ocp-Apim-Subscription-Key' = $OcpApimSubscriptionKey
}
# Making the request into API
Invoke-RestMethod -Uri $ApiUrl -Method GET -Headers $Headers -Verbose