When you try to access github repository from remote client or from automated program it requires you to login github account. For most use cases login with username and password works. However as we discussed earlier if you are using private github setup by your organization on enterprise cloud then your may require alternative authentication method because SAML SSO login wont allow authentication with sso username and password. Using an alternative authentication like access token or ssh keys would allow you to login github repository remotely. In this tutorial we will demonstrate github login with personal access token.
Steps
Generate Access Token from Github Account
- Login Github Account and move to Settings → Developer settings → Personal access tokens.
- Generate token by configuring required privileges on the token and provide meaningful name.
- Preserve the newly generated token and use it as password for subsequent logins with sso username.
Authentication Using Access Token
Windows
If you are using windows git client then you should provide username and generated token as a password in windows security pop up like below.
git clone https://github.example.com/techmonger/project-repo
Linux
On Linux command line you will be asked for the username and password before connecting to github repository. Provide Github username and generated token as password.
$ git clone https://github.example.com/techmonger/project-repo
Cloning into 'project-repo'...
Username for 'https://github.example.com': techmonger
Password for 'https://techmonger@github.example.com':
How does this authentication works ?
When you make login with generated personal access token it makes use of HTTP basic authentication protocol to validate user login session. Which means that you can use this authentication token to make call to github API as well.
Conclusion
In this tutorial we learned how to overcome SAML SSO login issue by using an alternative token based authentication to connect github repository remotely.