Maven repository with OAuth2 (or any other HTTP header authentification)

I am trying to use a Gitlab repository as private maven repository for my dependencies. The deployment process works fine (similar as described here, but much more simplified).

No I am trying to add the dependency, which does not seem to work. In maven, this seems to be possible (as described here: https://ubs-soft.com/maven-private-repository-in-gitlab/). But in Gradle only BasicAuth or s AWS s3 tokens seem to be supported (https://docs.gradle.org/current/userguide/repository_types.html).

Is there any way to add custom headers to the requests to a maven repository? Or is there any way to use OAuth2-authentification?

If not, can you give me a hint where to start to implement it?

Thanks!

For whom this might be interesting: https://github.com/gradle/gradle/pull/5621