1 00:00:00,830 --> 00:00:04,120 In the last video we wired up the API library to our project. 2 00:00:04,190 --> 00:00:09,060 We then loaded in some additional code to the library and then we initialized the authentication client 3 00:00:09,110 --> 00:00:10,590 with our client id right here. 4 00:00:10,670 --> 00:00:12,780 And we asked for a scope of e-mail. 5 00:00:12,860 --> 00:00:16,700 Now in this video I want to show you some documentation around this library and help you understand 6 00:00:16,700 --> 00:00:18,450 how to interact with it in general. 7 00:00:18,620 --> 00:00:24,770 So quickly Greg you're this is kind of a long link to the documentation for this API client library 8 00:00:25,010 --> 00:00:32,190 so you can either copy that link into your browser or you can just do a google search for API documentation. 9 00:00:32,330 --> 00:00:35,580 I'll do the Google search just to make this little bit easier for you to find. 10 00:00:35,810 --> 00:00:41,920 So I can open up a new tab and search for the API documentation and then I should see a first link of 11 00:00:41,930 --> 00:00:42,740 something like. 12 00:00:42,740 --> 00:00:46,540 Developers start Google dot com API client library blah blah blah. 13 00:00:46,740 --> 00:00:47,720 So I'm going to go there. 14 00:00:47,720 --> 00:00:51,530 We'll take a look at some of the different methods and classes available on this library. 15 00:00:51,530 --> 00:00:54,580 Now of course if you want to you can also look at the guides or samples. 16 00:00:54,590 --> 00:00:58,610 It's totally up to you but frankly if you look at the documentation that's going to give you a pretty 17 00:00:58,670 --> 00:01:01,760 clear answer on how we interact with this library. 18 00:01:01,760 --> 00:01:07,370 All right so on this right hand nav I'm going to find the authentication section right there and then 19 00:01:07,370 --> 00:01:07,980 I'll click on it. 20 00:01:08,000 --> 00:01:10,930 We'll take a look at some of the different methods that are available to us. 21 00:01:11,700 --> 00:01:12,050 OK. 22 00:01:12,050 --> 00:01:20,240 So authentication section we can call the API off to get off instance when we call that method is going 23 00:01:20,240 --> 00:01:22,850 to return a google off object. 24 00:01:22,910 --> 00:01:27,650 This Google Earth Object has a ton of different functions signed assigned to it that allow us to figure 25 00:01:27,650 --> 00:01:32,870 out whether or not the user is signed in Currently we can initiate the flow and we can also use that 26 00:01:32,870 --> 00:01:34,670 to sign that user out. 27 00:01:34,670 --> 00:01:39,950 Remember when I told you that this client side of the flow is really easy to work with it's basically 28 00:01:39,950 --> 00:01:42,110 all because of the methods that you see right here. 29 00:01:42,110 --> 00:01:49,040 It's just really easy to figure out if the user is signed in to a event listener right here to figure 30 00:01:49,040 --> 00:01:50,970 out any time that the user does sign in. 31 00:01:51,110 --> 00:01:56,800 We can initiate the flow and all that kind of good stuff all through this library. 32 00:01:56,810 --> 00:02:00,740 Now let's flip back over to our consul inside the browser and we'll try working with this thing a little 33 00:02:00,740 --> 00:02:06,050 bit and just try calling a couple of of these different functions and seeing how they work. 34 00:02:06,050 --> 00:02:08,190 All right so I'm going to flip back over. 35 00:02:08,390 --> 00:02:10,150 I've got my counsel open right here. 36 00:02:10,340 --> 00:02:14,450 Now the first thing I want to do is get a reference to that Auth. instance object. 37 00:02:14,510 --> 00:02:19,240 So I'm going to say Konst auth equals G API. 38 00:02:19,280 --> 00:02:24,700 Off to get off instance. 39 00:02:24,810 --> 00:02:29,440 So now I should be able to reference off and see a object like this appear. 40 00:02:29,570 --> 00:02:33,590 Now when you look at this object right you're going to see a couple of different methods attached to 41 00:02:33,590 --> 00:02:38,900 it that appear to be coming from the documentation we were just looking at or example I see a sign in 42 00:02:38,910 --> 00:02:42,240 method right there and a current user method right there. 43 00:02:42,260 --> 00:02:47,330 And so you're going to see both those lists inside the documentation or example here is the sign in 44 00:02:47,330 --> 00:02:52,490 method and I'm sure we could scroll around and find some the others on here as well but you'll also 45 00:02:52,490 --> 00:02:57,020 notice that there are some of these very strange key value pairs inside if you're with like some randomly 46 00:02:57,020 --> 00:03:01,760 generated keys like capital BT or FDA and those are all methods. 47 00:03:01,760 --> 00:03:06,890 So all these randomly generated keys that you see are essentially private methods that are only used 48 00:03:06,920 --> 00:03:12,230 internally by this library and there is zero reason for us to ever try to call any of these different 49 00:03:12,230 --> 00:03:13,000 functions. 50 00:03:13,130 --> 00:03:18,180 They are essentially functions that are built in here for the internal operation of this library. 51 00:03:18,290 --> 00:03:23,450 You and I are only ever going to reference properties or methods inside this Google API library with 52 00:03:23,540 --> 00:03:29,190 very plainly defined names such as is signed in or sign in or sign out. 53 00:03:29,210 --> 00:03:31,020 And so on OK. 54 00:03:31,020 --> 00:03:35,680 So with that in mind let's try now triggering the flow for the user manually. 55 00:03:35,920 --> 00:03:40,560 So rather than clicking on any button or anything like that we're going to just try to manually use 56 00:03:40,560 --> 00:03:43,670 this object right here to get the user to sign it. 57 00:03:43,740 --> 00:03:48,230 So to do so basically all we do is call that sign in method. 58 00:03:48,240 --> 00:03:55,390 All right so I'm going to call off dot sign in like so and when I do so you're going to immediately 59 00:03:55,390 --> 00:03:57,820 see a pop up window appear right here. 60 00:03:57,850 --> 00:04:00,100 You can then select when you get your different Google accounts. 61 00:04:00,100 --> 00:04:05,850 I've got a couple so I'm going to select one of these once and that's going to essentially sign me in. 62 00:04:05,930 --> 00:04:11,150 Now I've already signed in under this project before so I've already granted access to my profile to 63 00:04:11,150 --> 00:04:12,610 the project we've just created. 64 00:04:12,680 --> 00:04:17,860 But you might get a little question saying something like hey are you sure that you want to allow me 65 00:04:17,900 --> 00:04:20,950 to get access to your e-mail address or something like that. 66 00:04:21,020 --> 00:04:23,840 You also sometimes might not see any pop up at all. 67 00:04:23,840 --> 00:04:26,810 So if you don't see any pop up break like that totally fine. 68 00:04:27,640 --> 00:04:33,010 In order to figure out whether or not you just successfully signed in we can again use this off object. 69 00:04:33,400 --> 00:04:40,840 So one of the properties on here one of the methods is is signed in right there so we can also go and 70 00:04:40,840 --> 00:04:46,280 check the documentation right here you'll see that we can call Google off. 71 00:04:46,280 --> 00:04:51,970 Dot is signed in get and that's going to return either a boolean true or false if the user is signed 72 00:04:51,970 --> 00:04:53,470 in or signed out. 73 00:04:53,500 --> 00:05:02,500 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 74 00:05:02,500 --> 00:05:07,330 right here and that tells me that I am currently signed into Google via US. 75 00:05:07,360 --> 00:05:12,760 So in theory if we had asked for any other scopes around this user such as the ability to modify their 76 00:05:12,790 --> 00:05:19,980 email or their Google Drive files we could now use this library to modify those files or those emails. 77 00:05:20,020 --> 00:05:22,870 But as we said earlier we're not going to actually be doing a lot of that stuff. 78 00:05:22,870 --> 00:05:27,160 We really just want to have the user to be able to sign in to our application and that's pretty much 79 00:05:27,160 --> 00:05:27,860 it. 80 00:05:28,260 --> 00:05:28,580 OK. 81 00:05:28,590 --> 00:05:33,450 Now that we understand how to generally work with this API library let's take a quick pause. 82 00:05:33,520 --> 00:05:38,860 When we come back the next section we're going to make sure that any time we render this Google off 83 00:05:39,220 --> 00:05:44,860 to the screen we try to show a button that the user can click to then sign in or eventually sign out. 84 00:05:44,920 --> 00:05:46,830 So quick pause and I'll see you in just a minute.