In the last video we wired up the API library to our project.
We then loaded in some additional code to the library and then we initialized the authentication client
with our client id right here.
And we asked for a scope of e-mail.
Now in this video I want to show you some documentation around this library and help you understand
how to interact with it in general.
So quickly Greg you're this is kind of a long link to the documentation for this API client library
so you can either copy that link into your browser or you can just do a google search for API documentation.
I'll do the Google search just to make this little bit easier for you to find.
So I can open up a new tab and search for the API documentation and then I should see a first link of
something like.
Developers start Google dot com API client library blah blah blah.
So I'm going to go there.
We'll take a look at some of the different methods and classes available on this library.
Now of course if you want to you can also look at the guides or samples.
It's totally up to you but frankly if you look at the documentation that's going to give you a pretty
clear answer on how we interact with this library.
All right so on this right hand nav I'm going to find the authentication section right there and then
I'll click on it.
We'll take a look at some of the different methods that are available to us.
OK.
So authentication section we can call the API off to get off instance when we call that method is going
to return a google off object.
This Google Earth Object has a ton of different functions signed assigned to it that allow us to figure
out whether or not the user is signed in Currently we can initiate the flow and we can also use that
to sign that user out.
Remember when I told you that this client side of the flow is really easy to work with it's basically
all because of the methods that you see right here.
It's just really easy to figure out if the user is signed in to a event listener right here to figure
out any time that the user does sign in.
We can initiate the flow and all that kind of good stuff all through this library.
Now let's flip back over to our consul inside the browser and we'll try working with this thing a little
bit and just try calling a couple of of these different functions and seeing how they work.
All right so I'm going to flip back over.
I've got my counsel open right here.
Now the first thing I want to do is get a reference to that Auth. instance object.
So I'm going to say Konst auth equals G API.
Off to get off instance.
So now I should be able to reference off and see a object like this appear.
Now when you look at this object right you're going to see a couple of different methods attached to
it that appear to be coming from the documentation we were just looking at or example I see a sign in
method right there and a current user method right there.
And so you're going to see both those lists inside the documentation or example here is the sign in
method and I'm sure we could scroll around and find some the others on here as well but you'll also
notice that there are some of these very strange key value pairs inside if you're with like some randomly
generated keys like capital BT or FDA and those are all methods.
So all these randomly generated keys that you see are essentially private methods that are only used
internally by this library and there is zero reason for us to ever try to call any of these different
functions.
They are essentially functions that are built in here for the internal operation of this library.
You and I are only ever going to reference properties or methods inside this Google API library with
very plainly defined names such as is signed in or sign in or sign out.
And so on OK.
So with that in mind let's try now triggering the flow for the user manually.
So rather than clicking on any button or anything like that we're going to just try to manually use
this object right here to get the user to sign it.
So to do so basically all we do is call that sign in method.
All right so I'm going to call off dot sign in like so and when I do so you're going to immediately
see a pop up window appear right here.
You can then select when you get your different Google accounts.
I've got a couple so I'm going to select one of these once and that's going to essentially sign me in.
Now I've already signed in under this project before so I've already granted access to my profile to
the project we've just created.
But you might get a little question saying something like hey are you sure that you want to allow me
to get access to your e-mail address or something like that.
You also sometimes might not see any pop up at all.
So if you don't see any pop up break like that totally fine.
In order to figure out whether or not you just successfully signed in we can again use this off object.
So one of the properties on here one of the methods is is signed in right there so we can also go and
check the documentation right here you'll see that we can call Google off.
Dot is signed in get and that's going to return either a boolean true or false if the user is signed
in or signed out.
So now that I have signed in I'm going to reference off dot is signed in get and then I get a true response
right here and that tells me that I am currently signed into Google via US.
So in theory if we had asked for any other scopes around this user such as the ability to modify their
email or their Google Drive files we could now use this library to modify those files or those emails.
But as we said earlier we're not going to actually be doing a lot of that stuff.
We really just want to have the user to be able to sign in to our application and that's pretty much
it.
OK.
Now that we understand how to generally work with this API library let's take a quick pause.
When we come back the next section we're going to make sure that any time we render this Google off
to the screen we try to show a button that the user can click to then sign in or eventually sign out.
So quick pause and I'll see you in just a minute.