IntelliJ kept downloading Gradle from services.gradle.org even with a custom distributionUrl because SourceDistributionProvider hardcoded it. That was fixed in the Gradle release containing PR #37099, so upgrade Gradle. If you mirror through Artifactory behind a proxy and still hit auth issues, check that the server sends a Basic auth challenge on HEAD (curl -i --head on the distribution URL); Gradle only retries with credentials after a challenge.

_Source: gh:gradle/gradle#27863 (Gradle)_