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: But in Gradle only BasicAuth or s AWS s3 tokens seem to be supported (

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?


For whom this might be interesting: