[MUSIC] The first part of OAuth2 that we need to undertake is to go to the web service and register as a developer. In this case we're gonna go register with Instagram. But generally speaking, if you wanna find data out on the internet, you're gonna have to do the similar thing with slight variations with other services. Things that I can think of off the top of my head is Flickr you need to do this, Instagram obviously. You can just kind of search on the internet for web APIs if you're interested in finding one and then you can find a whole lot of them. Actually this programmable web directory has tons and tons of different services, YouTube, Google Maps, Amazon, Twilio, eBay. They all have different kinds of data services that you can access, most of them protected by OAuth. Then one that we're interested in is Instagram. So let's go there. Okay, and what we're interested is we're interested in registering as a developer with an API. So here's the API click link down here. So let's click on that for a second. Oh, look, hello developers. Great, so, all this information about how to use the API with Instagram, it's pretty elaborate, but I know that the first thing we have to do is we have to log in. So, I'm gonna log in as myself. Okay, so now I'm logged in. That's great. And what I want to do. Let's go ahead and save my password so I don't have to do that again. Oh look, here's the link right here. Register your application. Okay, great. Okay, so what's the website gonna be. Well, whatever you've got. This isn't part of the flow. So I'm just going to go ahead and put my personal website in there, my phone number, I guess. And what do you want to build with the API? I'm going to build an application for Coursera students. Okay, check the terms of use in the brand guidelines, which talk about how you can talk about the fact that you're using Instagram without getting in trouble. And you wanna make sure you don't get in trouble because they can always reject your credentials if they don't like what you're doing. That's another reason why OAuth 2.0 is helpful for the services. All right, so sign up, great. Developer. The next thing that I wanna do is I want to, I thought I already registered that. I want to manage my client, so let's see. Authentication, no. Here, Manage Clients, up here. And I'm gonna register a new client. In this case, in OAuth 2.0 terminology, the client is the software that's requesting access on behalf of the user for the data on Instagram. So let's register that new client. Our application's gonna be called GrammyPlus. And, oops, they say don't use Instagram, IG, insta or gram in your app name. Hopefully GrammyPlus will be okay. This is an example app for Coursera. It doesn't end in gram so hopefully we're okay. Website URL, I'll go ahead and put my website down again. And then for Redirect URL this is, it says here the Redirect URL specifies where we redirect users after they have chosen whether or not to authenticate to your application. And this is the spot where we need to put that funny URL scheme in so that our app can catch it. And so what I'm gonna do is, I'm gonna go ahead and use grammyplus:// and so instead of HTTP I'm putting grammyplus and we'll just put authenticated as our redirect URI. Down here in the contact information I'll go ahead and put my email and to make sure that I am not a robot, I'm gonna type in the letters that are in that. Okay, go ahead and register. What did I do? Valid, oh, that's right. I'm sorry. There's a workaround that you've gotta do here in this software. You have to enter in a valid url and then go back and change it. So just make something up for now. Click on security. No, we explicitly want implicit OAuth, so we have to un-check that. We're explicitly doing implicit OAuth. And then type the words above. Okay, looks like 1629 to me. Let's try to register that again. Holy cow. What in the world is going on here? Valid, redirect URIs, And I don't understand what that is. Let's try that one. It's not letting me put a redirect URI. You know what, I'm gonna retry this in Safari to see if it's a browser problem. You know what, I'm going to take that back. I think what I'm gonna do is I'm gonna reopen this window again in a new tab. So close that. Sam and I were running into this problem before. I'm trying to remember off the top of my head what the problem was. Grammyplus. This is an example app for Coursera. And what did we do? Make sure under security we want that. We want blocked. Okay, so we ran into this problem before, it's something with Instagram. I think it involves having to refresh the page and try again. So you can see that you might run into some trouble with that redirect line. So here we picked a redirect URI, that's scheme://thing.com. So we're gonna try and grab scheme when we are in our app. Now, what we've got there is we've got some important information that we wanna grab. So, we wanna grab our client ID. Wanna copy that, wanna paste it in something we can look at later. Our client secret. Wanna grab that, paste it here. The website URL, that's for us. The redirect URI is here. That's fine. Oops. All right, then the authorized URL and the token URL, they come from the service that you wanna use. So now we have to look into the API and we have to say, okay what do we want from our service? Now we need to see what kind of information do we actually wanna get from Instagram. And what I'm looking for is I'm trying to look for the most recent image that I have shared, my own share. So that's going to be down here under Endpoints or the different functions calls that you can call with the api. So under users this self media link see the authenticated users list of liked media. Nope I want to see the authenticated users feed. So if I do that, you come down here and you can say oh great. So here is the URL that I'm interested in, in order to get the information about a user's feed. And then I'm interested in the response. And holy cow, what is that? That is some crazy data right there. Well, look at that. It goes on and on and on, all the way to there. I'm gonna copy it for a second, paste it over here. What we're looking at right here is something called JSON. JSON is a kind of data that you get from a web service like this. And that's something that we need to talk about a little bit. This is the common way that data is communicated. We see that if we ask Instagram to give us this feed of a user, we're gonna get all this data back. And as I look down here, this URL right here looks like something that I wanna grab. So, maybe like a standard resolution Image. If I were able to get that URL, that would be a recent image that was shared on my feed. That's what we want, but we need to talk a little bit more about JSON in order to make that happen. So, next, let's step back for a second. Let's talk about JSON, at a high level, so that we understand what we're working with when we come back to Instagram. Thanks. [MUSIC]