WebRTC softphone registration fails with 401 Unauthorized in Terraform pipeline

Can anyone explain why the softphone configuration resource fails during apply?

The genesyscloud_user resource applies successfully, but the subsequent API call to /api/v2/users/{userId}/webphone returns 401 Unauthorized.

Environment details:

  • Terraform v1.9.2
  • Genesys Cloud Provider v1.31.0
  • Region: ap-southeast-2
  • OAuth Client ID: valid and active

Snippet:

resource "genesyscloud_user" "agent" {
 name = "Test Agent"
 email = "[email protected]"
 username = "[email protected]"
}

resource "genesyscloud_webphone_config" "default" {
 user_id = genesyscloud_user.agent.id
}

Error log shows the bearer token is expired or invalid at the moment of the webphone call. Is there a known race condition in the provider?

You need to check the OAuth scope configuration.

Cause: The webphone endpoint requires specific admin privileges not included in standard user scopes.

Solution: Update the client secret with the webphone:write scope. In Terraform, ensure the genesyscloud_oauth_client resource includes this scope before referencing it in the user resource. This resolves the 401 error.