Tech Monger

Programming, Web Development and Computer Science.

Skip to main content| Skip to information by topic

Github Configure Token Based Authentication

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

  1. Login Github Account and move to SettingsDeveloper settingsPersonal access tokens.
    Generate Personal Access Token
    New Personal Access Token - Github
  2. Generate token by configuring required privileges on the token and provide meaningful name.
  3. Access Control on Github Personal Tokens
    Github Token - Access Controls
  4. Preserve the newly generated token and use it as password for subsequent logins with sso username.
  5. Newly Generated Github Access Token
    Github Personal Access Token

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
Github Token Login on Windows
Github Access Token Login - Windows Security Credential Manager

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.

Tagged Under : Git Github Linux Windows