-
-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clone repo from googlesource.com #768
Comments
That looks like an invalid URL to me - unless you have some indication that this works with C Git? AFAIK googlesource.com doesn't support the git:// protocol. |
|
You're using a different URL in Dulwich - the URL you had in the fragment you posted used the "git" URL scheme, not "http". This repository is not available over the plain git protocol. |
So the URL The following two commands work fine on my computer.
|
Yes, that URL is supported, but it's not the URL you are using in your code fragment. You're specifying the git:// protocol to Dulwich, not https://. You're using https in your git command. Dulwich supports both git:// and https://, but Googlesource only supports https. |
I did try https, but it didn't work. See below.
|
That's indeed because of authentication - you can specify the credentials in the URL, i.e. https://username:password@earthengine.googlesource.com/users/google/dataset |
Unfortunately, providing username and password is not an option. I am using Dulwich for another Python package. I could not ask the user to enter the user name and password. Once users authenticate Google Earth Engine by logging to their Google account, credentials are saved under the user directory (e.g., ~/.config/earthengine/credentials). I can use git clone without having to enter user name and password. Can Dulwich do the same thing? Thanks. |
How does git retrieve the credentials from ~/.config/earthengine/credentials? I'm pretty sure you'd need some kind of helper to do that, and that it doesn't check that location by default. Either way, I'm afraid the Dulwich porcelain doesn't do any credentials retrieval itself. You can pass credentials into it that you've retrieved somewhere else, but it doesn't go out looking for credentials itself. That's probably not going to be a two line solution though. You could take care of retrieving the credentials by parsing ~/.config/earthengine/credentials, and then pass those into dulwich? |
@jelmer Thanks for your insights! I am not sure how git retrieves the credentials. I simply create a new Jupyter notebook, then execute |
it probably has a Git credentials helper that can provide the credentials - see https://www.git-scm.com/docs/gitcredentials dulwich does not support reading credentials from gitcredentials helpers, but that is not properly hooked up yet in the porcelain unfortunately. If you try this again in a couple of months it may work. |
@jelmer Good to know. Thank you very much for your help. I am closing this issue for now. Will check back dulwich in a couple of months. |
Just wanted to share my solution for this. Although GCP does provide a credential helper, in the form of:
all this does is obtain an oauth2 access token for the authenticated user, which is then used (along with the username) for basic http auth. Fortunately it's quite trivial to obtain an access token in python code; see https://google-auth.readthedocs.io/en/master/user-guide.html import urllib
import google.auth
from google.auth.transport.requests import Request
from dulwich import porcelain
creds, _= google.auth.default()
creds.refresh(Request())
username = urllib.parse.quote("<USER>@<GOOGLE_ACCOUNT_EMAIL>")
password = creds.token
porcelain.ls_remote(f"https://{username}:{password}@source.developers.google.com/<MY_REPO_PATH>") |
It seems duwich could not clone repo from googlesource.com. Any advice? Thanks.
The text was updated successfully, but these errors were encountered: