Issue with GitLab CI Job Token for Scala SBT Dependency Resolution

Hello everyone,

I’m encountering an issue with using the GitLab CI job token to download dependencies in a Scala SBT project. While the CI job token works smoothly in a Maven project, it’s throwing an “unauthorized” error in Scala SBT, both locally and on GitLab runners. However, using a private access token works without any issues. The gilcloud plugin is able to publish in the packages registry with the CI job token.

addSbtPlugin("com.gilcloud" % "sbt-gitlab" % "0.1.2")

import com.gilcloud.sbt.gitlab.GitlabPlugin
import com.gilcloud.sbt.gitlab.GitlabCredentials
lazy val root = (project in file("."))
  .enablePlugins(GitlabPlugin)
  GitlabPlugin.autoImport.gitlabGroupId := Some(xxxx) 
GitlabPlugin.autoImport.gitlabProjectId := Some(xxxx) 
GitlabPlugin.autoImport.gitlabDomain := "gitlab.com" 
GitlabPlugin.autoImport.gitlabCredentials :=  Some(GitlabCredentials("Job-Token", sys.env.getOrElse("CI_JOB_TOKEN", ""))) 


resolvers += "Gitlab Maven Repository" at {
  val groupId = gitlabGroupId.value.getOrElse(sys.error("Gitlab project ID is not set"))
  s"https://${gitlabDomain.value}/api/v4/groups/$groupId/-/packages/maven"
}
credentials += Credentials(
  "GitLab Packages Registry",
  "gitlab.com",
  "Job-Token",
  sys.env.getOrElse("CI_JOB_TOKEN", "")
)

libraryDependencies += "com.edifecs.dmcloud.common.util" % "encryption-util" % "1.0"

But when I used this credentials with my own Private access token then It able to download the dependencies

credentials += Credentials(
  "GitLab Packages Registry",
  "gitlab.com",
  "Private-Token",
  "xxxxxxxxxxxxxxx"
)

Can any one please help me with this