WESLEY CHUN: Hey everyone, this is Wesley Chun,an engineer and developer advocate here at Google. If you've been wanting to integrate Google technologiesinto the apps that you create, thisis the right place to get started. In this episode, we'll cover the setup processwhen you want to build an app that uses Google APIs. First of all, why Google Developer Tools at all?Well, in the last episode-- clickthe link if you missed it-- we mentionedthat people are familiar with tools like Google Searchand YouTube. But can you imagine having to create your own GoogleMaps or Google Drive?Well, we can't either. There's no need to reinvent these wheels whenyou can use our APIs and open source developer tools to tapinto these technologies. Today, we'll show you how easy it is to get started. You'll learn how to create a project in the DeveloperConsole-- or DevConsole-- and howto enable the APIs you wish to use. Finally, you'll learn how to get the credentials your app needsto access Google APIs, whether you'reaccessing authorized data or using simple API keysto access public data. In upcoming episodes, we'll createscripts using these credentials to access Google APIs. This common code will be the same regardless of app,how may APIs it uses, or what language. By the way, if you're not accessing authorized data,the required code is even shorter. Your code will be able to access Google services from anywhere,whether it's a client-side web app, a mobile app,or a back-end service running in the cloud. Because the approach to all are very similar. All you need to do to get set up is done in the browser. So let's go to the computer now. All right, here we go. Any time you're running an app using Google APIs or the GoogleCloud Platform, you need to go to the Developer's Console,or DevConsole. So pop open a browser to console. developers. google. comand log in with your credentials if you haven't already. If you don't have a Google account yet,then click on the Create Account linkthat you see just below to get started. Once you're logged in, you'll be broughtto the DevConsole's home page, whichis an overview of all of your projects. Don't worry if you haven't created one yet. It'll just be blank instead of having a list of them. Here, we're going to be doing three things. One is to create a new project. Two is to turn on the APIs you'regoing to use for that project. And three, you're going to create and downloadthe appropriate credentials. To begin, let's create a project by clicking on the blue CreateProject button. You need to provide two things. One is the project name, which isused only here in the DevConsole--so you can change it later if you don't like it. The second thing you need to provide is a project ID. This uniquely identifies your projectover all the others in the system. And because of that, you can't change it later, so make ita good one. For your convenience, Google creates a random one for you,like the one you see here. If you don't like it, pick your own, if it hasn't alreadybeen chosen, or click on the little refresh wheel over here,and Google will make another random one for you. Once you've decided, click on Create. A bunch of gears will start spinning around inside Googledata centers to create your project. It usually takes about half a minuteto get the project set up. Once it's ready, you'll be taken to your new project'sdashboard, which is where we'll pick up. So go ahead and pause the video to dothat, then resume once you've landed on your new project'shomepage. Great, our project was created successfully. So here we are on our project's Overview page. To keep things simple, our projectwill just be a command line script. It could be also a mobile client or a server-side app runningin the cloud. We'll show you where those other options come in later. For now, the next step is to enable APIs. And yes, there is an app for that,which is this Enable an API button. You'll be taken to the services page, whereyou can turn on APIs you wish to use. You'll see that some Google Cloud Platform services havealready been enabled by default. So if you're not interested in using them,feel free to toggle them off using the switchesthat you see here on the right-hand side. Now it's time to find the APIs that you want to enable. For example, if you're interested in using the GoogleDrive API, just scroll down and flip it on. There it is. Next, let's say you wanted the YouTube data API. Well, you'd scroll down to find that and turn iton in the same way that you would turn on any other API. Once you're done selecting the APIs that you wish to use,scroll back up to the top to ensure that they'vebeen turned on, like we see here. Now let's set up our credentials by selecting that linkon the left. On this page, we see two sections-- authorizedand public API access. We're going to create credentials for both. For Google Drive, you should recognizethat files and folders are user data,meaning that your app needs to be authorized in order to getaccess to that type of data. So let's do that by clicking on the Create New Client IDbutton. Here, we see a dialogue to enter our application type. Since it's a simple command line script,it's neither a web app nor an app running on a Google serveracting on behalf of a user, whichis what a service account is for. Instead, we're creating an installed app, so select that. Now, it's neither a web nor a mobile installed app,but a command line script instead. So that means Other. Now click Create Client ID to generate your OAuthcredentials. The last step in this section is to click on the Download JSONbutton. This will save the credentials file that your script willuse in order to communicate with GoogleService for authorization. Naturally, we'll recommend you drop that fileinto the same folder as to where you're going to build your app,like we did here. So now that's done. Going back and taking a look hereat the second half of the Credentials page,we see this is for simple or public API access, meaningyou'll be creating an API key. It's primarily used for APIs where you're justaccessing the service, like searching for YouTube videos. In such cases, just having an API keyis good enough, as there's no need for authorization here. Click on the Create New Key button. Again, we have just a command line script,which is neither a web nor a browser app. So it's technically a server app, so select that. You can also choose to whitelist IP addresses if you wish. Otherwise, click Create. In a few seconds, you'll have an API key-- ta-da!This is a string that you can copy and paste directlyinto your code, which is fine for experimenting with. But obviously, this isn't secure in practice. So if you're doing this for production,make sure you put it into a secure databaseor someplace other than plain text and code, all right?Anyway, now you've got authorized and public APIaccess. So our mission in the DevConsole is complete. The rest is up you. All right, now that you've got a project set up,you're ready to start coding. In the next episode, we'll walk you through the common securitycode necessary to use Google APIs. Well, that's it for now. Be sure to bring your code editors next time. This is Wesley Chun from Google, and we'llsee you again soon on the Launchpad.
Source : Google Developers
EmoticonEmoticon