- To work with Git, you need credentials.
And you normally set these credentials up on the Git site
that you want to use.
You wanna use GitHub, go to github.com, create an account.
This account is a username/password combination.
And apart from username/password combination,
strong credentials are becoming more common.
And these strong credentials can be used
as authentication tokens while working with Git.
Tokens are also very useful
while addressing the API directly.
If you want to address the API directly from the software,
there shouldn't be any username and password involved
because who's going to type the password.
And also in Git, two factor authentication
has become common.
And this is implemented through an authenticator app
or by using SMS verification.
Now let me show you how to create a personal access token.
So here, I'm on github.com, I don't need to Sign Up.
I already have an account, so I'm using Sign In.
And here's my GitHub username and I am going to sign in.
Now this is the two-factor authentication, and that means
that I'm going to receive a message, on my phone
and this message contains once-only code
that I need to enter.
And after verification,
we can see that I'm in the Git environment.
So I need to go to My Account.
And in My Account, there is the Settings.
And in the Settings, we have the Developer Settings,
right here.
And in the Developer Settings,
there is the Personal Access Tokens.
And this Personal Access Tokens, that's what we need.
Now, I'm going to use the classic tokens.
Fine-grained tokens are a new development.
They're still in beta and in the fine-grained tokens,
you can better identify which actions
are allowed specifically.
So here, you can see a couple of tokens that I already have.
I am going to use generate new token
and I want to use a new token, classic.
Let me give you the name.
February 23.
By default, these tokens expire after 30 days.
The expiration all depends on how you want to use it.
If you don't need it to be the best possible security,
just select no expiration, to make it easier on yourself.
Now, next, we need to specify the scopes.
The scope defines the access for the personal tokens,
as you can see here.
So I want the repo scope.
I just want all scopes,
including the admin scope.
Within Git, you can work with role-based access control
in a pretty decent way
and I just want to make sure
that I have access to everything that is possible.
And then I click Generate Token.
And after generating the token,
we can see the token right here.
I'm going to copy this token
and I need to paste the token so that I can later use it.
That's what I'm going to do on my Linux machine
which is where I'm going to use these tokens.
(keyboard clicking)
I like to put them in a file.
And that makes it easier to use the tokens later on.
We will see, as we proceed,
how this token is going to be used but, at least,
we have a token at this moment
and that's all that matters now.
A relatively new feature that we need to talk about
is the Credentials Cache.
Because tokens are now the standard way to authenticate,
the global username and password settings no longer work
for authentication.
So if you don't do anything, you'll be prompted
for your username and password all the time.
And that is why a Credentials Cache should be created,
to cache your credentials.
To do so, you need a gh client
which is the GitHub client utility.
And you use personal access tokens
to establish your identity,
that is stored in a credential cache
and then you don't have to enter your username anymore.
So let me demonstrate how to do.
Here on the slide, we have the steps summarized.
Let me show you.
So here I am, in my browser,
and I'm going to use install gh client.
It's probably best to just Google it.
Installation instructions, that's what I want.
So here you can see the installation instructions
for all the different operating systems
and we are going to look for Linux.
Linux installation instructions.
There we go.
So here you can see for the different distributions,
what exactly to do.
You can go for the manual installation.
You can also use your Package Manager.
Now, you can see that apparently on ubunto,
you don't have to configure anything
for Fedora, CentOS, and family.
You need to install from the package repository
for immediate access to the latest releases.
So we need to add the repository first.
So let me set up this repository stuff
and install the gh client utility.
(utility installing)
So client utilities installed.
Now I need a gh auth login,
and that is the magical command
that will create the Credentials Cache for us.
Read carefully so that you're doing the right thing.
So it wants to know which account I'm going to use.
I'm going to use a github.com account.
My preferred protocol is HTTPS.
And yes, we want to authenticate with the Git credentials
and I want to paste an authentication token
and I'm pasting the authentication token.
And there you can see based on the authentication token,
it's logging me in.
So it's telling me log in as sandervanvugt,
so it knows me now and it means that I don't need
this user information anymore.
So let's go and use some Git.