configure teamcity with github, why do i need a git password if i use OAuth? - github

i'm trying to configure teamcity with my github.
the first step was to use OAuth in git in order to secure the connection between teamcity and git, that seemed to work ok, and now, when i go to add a new VCS root, i can see all of my git repositories and choose from them.
the issue i have is when i try to add this VCS root, i choose a git repository, and then i need to enter a username and password.
my question here is why do i need to enter my git username and password if i'm using Oauth? my connection to git is already secured, and i could see all of the repositories to choose from.
if i change the "Authentication method" to "Anonymous" it doesnt work, the only way the connection is working for me is if i use my git username, and my git token.

When you connect TeamCity to GitHub with help of OAuth, you grant TeamCity server permissions to make REST API calls to GitHub on your behalf. But to checkout source code this is not enough. Simply because your git executable knows nothing about OAuth tokens and all these OAuth specific flows. It expects a password or SSH key.
So for this to work TeamCity needs to generate something that can be used as a password. Fortunately in case of GitHub a regular OAuth token can be used as such because it's permanent. Bitbucket cloud does not have permanent tokens, instead they propose using Application passwords. But there is no way to generate such passwords on behalf of a user... So with Bitbucket and private repository only user can generate and type in this password.
There can be a confusion associated with "Password" word in TeamCity web interface. But there is no common notation even among popular Git hosting services. Maybe if you start thinking in terms of Git client, then it will makes sense. For Git client this is indeed a password.

Related

GitHub - How to clone repository on a shared server without giving access too all my repos

My question is the same as Github add SSH key from others will grant access to all repos?, except my use case is that I am working on a shared server with other contributors. We all need access to a certain repository on this server. However, since GitHub requires SSH now, how can I clone and use the repository without adding my SSH key to the server and allowing everyone else access to all of my personal repositories?
I have already added my teammates as contributors in the repo we want to clone; it would be nice if we could each individually use our username and passwords to interface with the repo (like the old HTTPS method of cloning git repositories) without having to share our private keys with each other. If there is an option to only allow SSH access to a specific repo, that would be nice as well.
The only workaround I can think of right now is to create a dummy GitHub account with the sole purpose of accessing this repo, and registering our SSH key with that GitHub account. But this seems very contrived and I'm wondering if there is a better solution to this problem.
A dummy github account with only the right permissions to access the one repo is what GitHub calls a Machine Account and is the recommended way to provide access under scenarios like these.
Alternatively, you could use a deploy token, those are bound to a single repo by default.

Eclipse Git (Egit) not accepting remote username and password

Why doesn't Egit accept username and password when fetching from remote?
These are the steps I follow:
In Git Repositories view I expand Project -> Remotes -> origin
Right click on origin -> fetch
Login mask appears; I insert User and Password
Repeat step 3 other two times
An error message appears: https://companyname.visualstudio.com/.../projectname: not authorized
Credentials are correct and I am authorized because I use them daily with any kind of git interface: TortoiseGit, SmartGit, Git Bash, ...
I did research but didn't find this problem. Also similar questions don't address this problem.
Update: I used a workaround following this guide. I created an access token from the Visual Studio Team Services account and I'm using that as password.
My git installation is using Git Credential Manager (GitHub page, Microsoft guide to GCM) to store credentials, in fact when I ran for the first time git through the interfaces I mentioned above and tried to connect to the Team Services Git repository the Microsoft Account login window popped up and that was it. Also I can tell it from runnig the command git config --list and getting credential.helper=manager.
Eclipse has the Team Explorer Everywhere plug-in installed, so it should interact with Git Credential Manager and accept the Microsoft Account credentials, but it doesn't. So this is still an open issue.
I was facing the same issue
From git side
settings-->developer settings-->Personal access tokens-->generate new token-->copy that token and use that token as password.
The way to fix this is to go to
Window->Preferences->Team->Git
And then change the HTTP client from Apache HTTP to Java Built-in HTTP
The Git clients you mention uses "native" git, and the credentials are provided transparently during the communication with the server.
Eclipse git client (jgit+egit) is full-java based, and unfortunately you can't use native git in Eclipse.
Either your Git server has user+password locally (not so enterprise-ish!) or you could use Kerberos tickets in Eclipse git; but before you run Eclipse you should do a kinit to create a ticket with your user logon, that is accessible from java process. (Normally the ticket is in your user home directory)
Example using kinit:
I m not so sure about the TFS plugin, but maybe in your case it is worth to install it and see if it helps you instead of the embedded egit, see https://msdn.microsoft.com/en-us/library/hh301122(v=vs.120).aspx
I had the same issue, not able to update the username in eclipse pop up while pushing to Git. Irrespective of username, I have provided the generated git credentials password and it worked.
Use personal access token for https. Fine graned tokens are preferred.
Refer. https://cse132.engineering.wustl.edu/files/githubEclipseAuth/githubEclipseAuth.html

GitKraken won't let me clone from a private repo on GitHub

I've tried cloning a private repo (that I have access to) on GitHub and get this message:
Clone Failed
Could not connect to 'origin'. Double-check your remote url, then make sure you have access to do that action on that remote and try again.
I run Windows 10, I have connected Kraken to GitHub and ssh key works and I can push and pull repos to my other GitHub repos that are public just fine.
I was also able to clone the repo from the command line just fine.
For some reason, GitKraken does not use your existing HTTPS credentials to communicate with GitHub, nor does it use SSH on Windows. Instead it uses OAuth2, which means you need to grant OAuth2 access to GitKraken.
https://support.gitkraken.com/integrations/github
If no remotes or repositories are appearing in Add Remote or Clone, the likely cause is the need for an organization to allow access. GitKraken cannot see those repos when cloning or adding a fork unless the org specifically gives permission to GitKraken as an application.
First check to see if access is allowed to GitKraken from GitHub Applications
If access has been allowed, then the organization will need to allow Organization Approval
For details about third-party application restrictions view Third-party apps list
These are the steps I took and they worked for me:
You need to be an administrator in your GitHub Organization.
Access the GitHub GitKraken Application page and request access:
https://github.com/settings/connections/applications/a7557949433b7d282a76
You will see a list of your Organizations at the bottom. Click "Request access" if applicable.
If your Organization is not listed then you have other problems (are you using the correct GitHub user account? Are you a member of the Organization?)
This is what the page looks like for me:
Approve of the Access you just requested:
Access this page: https://github.com/organizations/YOUR_ORG_NAME/settings/oauth_application_policy
You can also access the page by going GitHub Settings > "Organization settings" > "Third-party access"
This page looks like this:
This is not the same page as your "Personal settings" > "Authorized applications" page ( https://github.com/settings/applications )
You should see GitKraken listed as requesting permission.
Click the Approve link to grant it access.
GitKraken should work now.
However, in my experience I don't reliably see the GitKraken request listed in the Requests list. I've contacted GitKraken Support for assistance.
You can use the "GitHub Enterprise" configuration instead of the "GitHub.com" configuration:
As the domain for your GitHub enterprise server just enter "GitHub.com".
Generate a personal access token.
This will work with all repos you have access to, even if the organization has not opted-in to allowing OAuth 2 apps to access them, and it works regardless of which version of GitKraken you're using (i.e. you don't need "Pro").
I had the same issue. I solved by disconnecting from my GitHub.com account in GitKraken. Then, when I tried to clone an organizational private repo, GitKraken asked me username and password. The repo was cloned successufuly.
The above answers are all correct, and granting access to your Github organization is still the recommended way to go if you want to take full advantage of GitKraken's features, but if your organization admins can't or won't grant access, Gitkraken supports SSH keys as well.
It'll only use them on existing repos if the URL of the remote is an SSH url (starts with ssh:), and it'll only clone over SSH if you allow it to generate its own SSH key. Go to Preferences > authentication > Github, and it should be able to clone any repo you have access to.

How do I checkout a GitHub project from command line as a Collaborator?

This seems like a simple question which should have a simple answer...
I'm trying to checkout a GitHub project. The project is owned by someone else, so someone else is the Owner. GitHub Collaborators have read/write access, and I have been granted collaborator rights on the project. Collaborators are slightly different than Contributors, who have simply provided a pull request in the past.
I'm trying to avoid the following because I do not want the source files in "read-only" mode:
git clone https://github.com/user/project.git
I feel like I need to identify myself, and send my password or SSH key. But GitHub's help at Which remote URL should I use? only discusses SSH in the context of a Desktop client. I guess they have an app they want me to use, but I don't really want to use one.
Note: I have information in Git's global config (user.name and user.email), but its not the correct information/credentials for these purposes.
How do I checkout a GitHub based project as a Collaborator from the command line?
Using the the HTTP endpoint instead of the the SSH one.
As an aside, when you say checkout do you mean clone, fork or pull?
for clone it would be similar to this:
git clone https://github.com/user/project.js.git
You will be prompted for your user name and password.

First time using github and want to know command to access a repository

I just installed github in ubuntu and i don't know the commands to login with my username and password and command to access a repository and work on it
Thanks
Best way for linux is probably to give github your public key in your settings page, rather than log in as such. Then you can add a github repository to your local repository with git remote add git#github.com:<repopath> and push/pull from it with git push and git pull respectively using SSH for authentication instead of username and password.
If you don't understand any of what I've just said, I'd recommend looking at some tutorials, like this GitHub help article or Try Git.