Use Bearer Token (Auth Header) with Http Transport

I have a maven repository which wants authentication via a token passed in a http header

“Authorization: Bearer yJhbGciOiJFUzI1NiJ9.eyJzdW…”

I looked into hacking this in via a custom url scheme (implementing ResourceConnectorFactory and PluginServiceRegistry) but couldn’t seem to make this work - it seems PluginServiceRegistry is very much only for internal use - found a couple of other forum posts here to that effect.

Any other creative ways on how I may be able to make this work?

Ideally I want to be able to do something like

repositories {
    maven {
        url 'https://path/to/repo'
        credentials(TokenCredentials) {
            token 'yJhbGciOiJFUzI1N...'
        }
    }

but ok with something a tad more disgusting (a way of say, transforming all http requests, putting the token as password in basic auth and mutating the header)

2 Likes

Hello,

Were you able to find a solution for this? I’m facing a similar issue with VSTS’s new maven repositories.

Thank you,
Shawn