title: ClientSecretCredential authentication failed: A configuration issue is preventing authentication - check the error message from the server for details
body: <p>I am trying to get the access token of the service principal using the following code.</p>
  <pre><code>$authUrl = &quot;https://login.windows.net/&quot; + $tenantid + &quot;/oauth2/token/&quot;
  $body = @{
    grant_type    = &quot;client_credentials&quot;
    client_id     = $serviceprincipalid
    resource      = &quot;https://management.azure.com/&quot;
    client_secret = $serviceprincipalkey
  };
  $response = Invoke-RestMethod –Uri $authUrl –Method POST –Body $body
  
  Write-Host $response
  Write-Output $response.access_token
  ##vso[task.setvariable variable=myToken;]$response.access_token
  </code></pre>
  <p>The above code is working perfectly at my local machine's PowerShell but it is giving the following error when I am running the same code base in the Azure DevOps pipeline.</p>
  <pre><code>ClientSecretCredential authentication failed: A configuration issue is preventing 
  authentication - check the error message from the server for details. You can modify the 
  configuration in the application registration portal. See https://aka.ms/msal-net-invalid- 
  client for details.  Original exception: AADSTS7000222: The provided client secret keys are 
  expired. Visit the Azure Portal to create new keys for your app, or consider using certificate 
  credentials for added security: https://docs.microsoft.com/azure/active- 
  directory/develop/active-directory-certificate-credentials
  Trace ID: 98787ui7-e8ae-4712-b8b5-7678u8765rt5
  Correlation ID: yhjnbv43-56sy-9ksy-b8b5-mj876yu78i90
  Timestamp: 2021-03-16 12:32:28Z
  There was an error with the service principal used for the deployment.`
  </code></pre>
  <p><a href="https://i.stack.imgur.com/EruoS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EruoS.png" alt="enter image description here" /></a>
  I checked the secret keys, but the secret keys not expired, it's expiry date is already set for the year 2022. And if it would expire then the code should not have worked at my local machine's PowerShell.</p>
  <p>Does anyone have any idea? please let me know to resolve this issue.</p>