Authentication with SPN and error

Hi everybody. I am trying to run terraform code from a github workflow. I have set up the correspondant secret, as per the azure-login documentation:

{
    "clientSecret":  "******",
    "subscriptionId":  "******",
    "tenantId":  "******",
    "clientId":  "******"
}

so that then I can use the action like

    - uses: azure/login@v2
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}

However, I am getting an error from terraform:

Error building ARM Config: Authenticating using Azure CLI is only supported as a User (not a Service Principal)

I know I can use the environment variables to authenticate, but is inconvenient: then I am exposing the client secret to all the tasks. In principal, using the az login should not require that. Am I doing something wrong, or this is really the way to do it?

Thank you!