The underlying AWS mobile CLI used in this course has changed it's API. If you're starting to learn AWS, you may want to try the latest course. We now recommend you take the AWS for Front-End Engineers (ft. S3, Cloudfront & Route 53) course.

Check out a free preview of the full Rapid Development on AWS: React, Node.js & GraphQL course:
The "Adding Auth to Make Images Private" Lesson is part of the full, Rapid Development on AWS: React, Node.js & GraphQL course featured in this preview video. Here's what you'd learn in this lesson:

Steve reviews an approach to use authentication within the application for users to upload their own, private images.

Get Unlimited Access Now

Transcript from the "Adding Auth to Make Images Private" Lesson

>> Steve Kinney: All right, so how do we implement authentication? So, the chance to redeem myself after having to do it by hand the other time. What is the command? What is the command we do all AWS mobile help stuff with?
>> Speaker 2: [INAUDIBLE] AWS mobile.
>> Steve Kinney: Yeah, AWS mobile. And what's for authentication?

[00:00:27] I can type, just type a thing or two and we'll see.
>> Speaker 2: User-signin.
>> Steve Kinney: User-signin, very cool. User-signin, and we'll do enable, we'll try it out with --prompt.
>> Steve Kinney: And here's hoping, we'll go to advanced settings. Again, we, for sound interference we turned our cell phones off. So the text messages is not really a great thing.

[00:00:53] We'll use email. Sure, all the defaults are fine with me, other than the phone part. Now, we'll do awsmobile push,
>> Steve Kinney: All right, cool, and now we're just going to wrap this in the authenticator. So do import, withAuthenticator awsmobile react, [COUGH] Go to bottom it'll say, withAuthenticator, and I'm gonna have to make a new account, cuz this is a different app.

[00:01:46] It's not like one global across all of your Amazon apps. Each one has its own of all of these resources. It's not shared across any of them. Now, if you wanted them to have the same one, you could grab the configuration from the backed directory. You can grab the configuration for all of the Cognito stuff you're using that user pulled they're using for one, and bring it over to another.

[00:02:09] That's totally a fine thing to do, but by default, they're all gonna be completely unique, all right? So let's see what we got here.
>> Steve Kinney: The authenticator is not defined. Now, if I go up which one did I spell wrong?
>> Steve Kinney: Authenticator,
>> Steve Kinney: Cool, all right, so I just spelled the first one wrong.

[00:02:43] So, we'll go ahead and Sign up.
>> Steve Kinney: All right, here's open.
>> Steve Kinney: Okay, we'll go ahead,
>> Steve Kinney: I got a verification code.
>> Steve Kinney: I was excited.
>> Steve Kinney: All right, and we're in. Cool, so now we've got authentication in place. It's really interesting without me talking about it a whole bunch, to see how actual quick that is to wire up with email verification and everything else.

[00:03:41] What I want to do, I want to make this all private. One thing I can do if I want to get this up and running quickly
>> Steve Kinney: I can say level private, and this is just gonna change the defaults. If you wanna have different levels at different worlds, you can like literally go on and do that for every given one.

[00:04:12] But this should be a private level for everything
>> Steve Kinney: So what's the first thing that you notice? What's not on my screen anymore?
>> Speaker 3: No images.
>> Steve Kinney: No images, why?
>> Speaker 3: They're not yours.
>> Steve Kinney: I didn't ask for the public ones, I asked for all of my privates ones.

[00:04:31] Which is super cool that means that already I'm getting images scoped from my user, right? Without a whole bunch of authorization, right? It's like yeah, we're just gonna get yours. Under the hood is actually putting in a directory under my user ID, which is what makes this possible.

[00:04:47] So it's actually the by default looking in there. Soil sensor? Sure,
>> Steve Kinney: All right, cool. And so now this is unique just to me.
>> Steve Kinney: And over ten seconds later guess what doesn't work? That URL, right? It's totally no good anymore. So if I even all of a sudden got to that computer, they went to the bathroom, I'm gonna right-click on whatever that is, that URL.

[00:05:23] I mean, they could have just dragged it off the screen, I got it up. What's the whole security thing? What if somebody has access to your computer, physically access, game over? But it does mean that this URL at this point, you can see request has expired which is super cool.

[00:05:38] Cuz again, didn't take me a lot of work to do a relatively sophisticated thing which is really, really neat.