Authenticate DVC python api with GitHub app credentials

Hi Folks,

I am trying to use dvc python api which refers to private GitHub repo.

dvc.api.get_url(
    path='data/data.json',
    repo='https://github.com/owner/private-repo.git'
)

Without any credentials I get dulwich.client.HTTPUnauthorized: No valid credentials provided error.

I have registered Github app and want to use credentials of same to do some operations using python api. Can someone help me with how do we provide credentials to dvc python api?

Hello @Harshad!
Do you have an ssh access to the repo?
Replacing https address with git address might help. In your case it could be:
repo='https://github.com/owner/private-repo.git'repo=git@github.com:owner/private-repo.git

hey, customizing Docker images to run my application which requires access to private repo makes difficult to enable ssh with rsa key, is there a secure way to provide the git access token to authenticate to the git repo while you are using dvc commands?

You could clone the repo yourself and use path to it instead of a url in get_url.

Anyone got a solution to this? I’m trying to run dvc.api.read in a Kubernetes container and am facing some issues. It seems that using the git@github.com syntax is causing the system to recognize git as being a username.