Using URL with OAuth token in giter8

30 views
Skip to first unread message

Akara Sucharitakul

unread,
Jun 3, 2015, 9:24:13 PM6/3/15
to git...@googlegroups.com
I'd like to use the OAuth token in the URL for project generation from template. The URL format is documented here and has the following format:

git clone https://<token>:x-oaut...@github.com/owner/repo.git

Alternatively we could also supply a token in a different way like .netrc. Obviously this does not work. As per the 0.6.9 code here we hardcode the jgit CredentialsProvider to ConsoleCredentialsProvider. So no matter what URL is used or a .netrc file is provided or not, it will always prompt for the user/password. It would not be too hard to implement a URLCredentialsProvider and chain it in front of ConsoleCredentialsProvider.

I see an oauth_authorization branch but it seems to be rather stale and not been touched for 3 years. I also see the jgit dependency in 0.6.9 goes to this version: 1.3.0.201202151440-r while jgit is already at 4.0. Version 3.5 and later provides a NetRCCredentialsProvider to parse the credentials out of a .netrc file. The same version also added ChainingCredentialsProvider allowing the use of multiple providers. So instead of implementing everything ourselves, it may be worth upgrading jgit to the latest to enjoy the new features provided on github.

Would this be of interest?

Thanks,
-Akara

Akara Sucharitakul

unread,
Jun 6, 2015, 2:38:20 AM6/6/15
to git...@googlegroups.com
Making pull request for 1st cut - try using command line. The command line git will support OAuth token in URL and all the latest goodies. Assumes git is in your path, which should be common for most developers. If git is not in path or not available, fallback to JGit.

This will solve the initial OAuth problem. Library upgrade + CredentialsProvider change may be a slightly bigger deal.

Thanks,
-Akara


On Wednesday, June 3, 2015 at 6:24:13 PM UTC-7, Akara Sucharitakul wrote:
I'd like to use the OAuth token in the URL for project generation from template. The URL format is documented here and has the following format:

git clone https://<token>:x-oauth-basic@github.com/owner/repo.git
Message has been deleted

Akara Sucharitakul

unread,
Jun 7, 2015, 6:33:48 PM6/7/15
to git...@googlegroups.com
Added commit to PR with JGit upgrade (to 4.0) and chaining credential provider to support .netrc as well as user/password from console. JGit does not seem to take OAuth tokens as the git command does when added to .netrc. It also does not seem to deal with OAuth token in the URL, or at least not the ones I'm having. But it should be sufficient for basic user/password-based .netrc authentication without using git command. For more advanced uses, the git command fills in the rest.

Thank you very much,
-Akara

On Wednesday, June 3, 2015 at 6:24:13 PM UTC-7, Akara Sucharitakul wrote:
I'd like to use the OAuth token in the URL for project generation from template. The URL format is documented here and has the following format:

git clone https://<token>:x-oauth-basic@github.com/owner/repo.git
Reply all
Reply to author
Forward
0 new messages