Using maven github as the resolver in SBT

Has anyone successfully used a resolver that points to with authentication?

I have tried the following

ThisBuild / credentials += Credentials("Artifactory Realm", "Foo", "my-github-user", "my-access-token-with-read-package-permission")

val githubResolverUrl = url("")
ThisBuild / resolvers += Resolver.url("Foo", githubResolverUrl)(Resolver.ivyStylePatterns)

But I get get this error
unauthorized: (GitHub Package Registry)

I tried putting the realm, username and password in ~/.ivy2/.credentials. But got the same error.


I did look into this a few months ago, and got it to work somehow. Then I learned there is a plugin which does it easily: