title: Powershell request Bearer token from api call
body: <p>I have a script in Powershell where I request a Bearer token to do some stuff later.
  The problem is, I always get a Bad-Request (400)</p>
  
  <p>In the body, I provide the clientId and ClientSecret, but it looks like the call is not using my credentials</p>
  
  <p>Can someone help me please?</p>
  
  <p>I searched a lot on the internet and tried some different things, but nothing worked so far.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>function GetBearer ([string]$clientId, [string]$clientSecret) {
      $tokenEndpoint = 'http://web-scsecur-sso.appliarmony.net/TokenService/connect/token'
      $body = @{  
          'client_id'= $clientId
          'grant_type' = 'client_credentials'
          'client_secret' = $clientSecret
      }       
  
      $params = @{
          Body = $Body
          Method = 'Post'
          Uri = $tokenEndpoint
      }   
  
      $token = Invoke-WebRequest -Uri "http://web-scsecur-sso.appliarmony.net/TokenService/connect/token" -Method POST -Body $body  -ContentType  'application/x-www-form-urlencoded' 
  
      Return "Bearer " + ($token.access_token).ToString()
  }
  </code></pre>
  
  <p>The output should be a Bearer token, but so far I received nothing.</p>