Authenticating a Flask API Using JSON Web Tokens

  Рет қаралды 175,159

Pretty Printed

Pretty Printed

Күн бұрын

Пікірлер: 187
@prettyprinted
@prettyprinted 4 жыл бұрын
Join my free course on the basics of Flask-SQLAlchemy: prettyprinted.com/flasksql
@yusufsalk1136
@yusufsalk1136 Жыл бұрын
This is by far the most underrated jsonify pronunciation. Great video by the way. Thanks.
@pratikrane149
@pratikrane149 5 жыл бұрын
Neat explanation. Everything straight to the point. Thanks a ton for sharing such quality tutorials! This helped me a lot in understanding jwt
@prettyprinted
@prettyprinted 5 жыл бұрын
I'm glad I could help.
@marcoio8742
@marcoio8742 3 жыл бұрын
Terrific! This is super useful. 3 years later, thank you
@noletovictor
@noletovictor 4 жыл бұрын
Perfect! That is exactly what I need! Thank you for this simple, fast and easy solution!
@prettyprinted
@prettyprinted 4 жыл бұрын
Glad it helped!
@笨土豆
@笨土豆 3 жыл бұрын
Thx for this video, i have learned several JWT video tutorial on youtube. Your video is most clear i ever seen these days. Very helpful thx
@AnikSardar
@AnikSardar 3 жыл бұрын
Best video on authentication. Extremely well explained.
@WilliamRosswpr101
@WilliamRosswpr101 7 жыл бұрын
Thanks for sharing this. It has been a huge help towards understanding JWT in Python
@prettyprinted
@prettyprinted 7 жыл бұрын
You're welcome! Thanks for watching.
@koodauskanava9096
@koodauskanava9096 7 жыл бұрын
Always use 401 for unauthenticated routes. 403 is forbidden logic, for example forbidden directory listing etc. Not related to authentication.
@prettyprinted
@prettyprinted 7 жыл бұрын
Thanks! I should have looked those up before recording the video. I always get them confused.
@mbonuchinedu2420
@mbonuchinedu2420 4 жыл бұрын
ANOTHER LIFE SAVER...... More blessing to you..................
@prettyprinted
@prettyprinted 7 жыл бұрын
Thanks for watching! Join the hundreds of others who have taken my Flask courses on prettyprinted.com
@stanleyjohn4670
@stanleyjohn4670 5 жыл бұрын
Can you show how to use JWT in Django? It's a sincere request, thank you.
@TeddyAndersson95
@TeddyAndersson95 7 жыл бұрын
So excited, to watch this! I also 100% sure you will deliver another awesome tutorial :D
@prettyprinted
@prettyprinted 7 жыл бұрын
I try my best!
@JulienPy
@JulienPy 7 жыл бұрын
Still your great and step-by-step approach style. Very appreciated!
@prettyprinted
@prettyprinted 7 жыл бұрын
I'm glad you enjoyed it!
@BRBallin1
@BRBallin1 5 жыл бұрын
Great introduction. Made a somewhat intimidating topic seem straightforward
@prettyprinted
@prettyprinted 5 жыл бұрын
Glad the video helped! Thanks for watching.
@koodauskanava9096
@koodauskanava9096 7 жыл бұрын
Very good tutorial. Useful stuff!
@Leo-fh7fu
@Leo-fh7fu 4 жыл бұрын
another beautiful video, thanks for sharing my friend, subscribed!!
@ThaEzioAuditore
@ThaEzioAuditore 7 жыл бұрын
Thank you thank you thank you a million times ! your efforts are very much appreciated
@prettyprinted
@prettyprinted 7 жыл бұрын
You're welcome! And I appreciate you for taking the time to watch.
@techsteering
@techsteering 3 жыл бұрын
Thanks a lot! This is exactly what I was looking for. You saved me tons of time. Thanks again. :)
@vic_shine
@vic_shine 7 жыл бұрын
Many thanks, Anthony! Brain storage was improved :)
@prettyprinted
@prettyprinted 7 жыл бұрын
You're welcome! Thanks for watching.
@v4ldevrr4m47
@v4ldevrr4m47 2 жыл бұрын
The best simple example. thanks
@rakeshingle
@rakeshingle 4 жыл бұрын
Thank you, This helped me a lot.
@andrewbartlett2091
@andrewbartlett2091 5 жыл бұрын
Really clear, very informative, thanks a lot
@prettyprinted
@prettyprinted 5 жыл бұрын
You're welcome! Thanks for watching.
@somed_9216
@somed_9216 5 ай бұрын
It was really helpful, thank you
@orlapa
@orlapa 3 жыл бұрын
Excelente tutorial, this is useful for someone starting with this. Thanks
@saguoran
@saguoran 5 жыл бұрын
2019, I found this video is useful. good contents.
@prettyprinted
@prettyprinted 5 жыл бұрын
I'm glad you like. Thanks for watching!
@mellimelloweb
@mellimelloweb 4 жыл бұрын
Thanks Anthony for your excellent work. Can you complete this video with the implementation of refresh token? That would be very great!
@СергейНаталенко-х2х
@СергейНаталенко-х2х 3 жыл бұрын
Огромное спасибо Ваше видео очень помогло мне в работе) Thank you very much!!!
@shreevidyas.r8275
@shreevidyas.r8275 2 жыл бұрын
Thankyou for this wonderful video... Now am able to know how to create token and storing them...Can you please provide the video on requesting using that token from that moment on.
@carloseduardodasilvaolivei8939
@carloseduardodasilvaolivei8939 3 жыл бұрын
Thank you very much this video helped me a lot
@zzakpk
@zzakpk 4 жыл бұрын
very helpful tutorial. Thank you.
@ikhsanrahman9703
@ikhsanrahman9703 5 жыл бұрын
cool, how about for refresh token. that happen when we try to keep user remain login inside
@christianduahmarfo5283
@christianduahmarfo5283 Жыл бұрын
How was the `prompt screen` possible? Did you use HTML for the Login form?
@Tbalbiza_POV
@Tbalbiza_POV Жыл бұрын
Thank you, very helpful !!!!!!!!!!!!!!!!!
@prettyprinted
@prettyprinted Жыл бұрын
You're welcome! Thanks for watching.
@charlieontheearth
@charlieontheearth 7 жыл бұрын
Thanks for this video. It's very helpful for me.
@prettyprinted
@prettyprinted 7 жыл бұрын
You're welcome! Thanks for watching.
@XBoysGaming22
@XBoysGaming22 6 жыл бұрын
This is nice! Great video!
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching!
@dhyanprasad5611
@dhyanprasad5611 Жыл бұрын
nice video. wanted to add that when i tried to authenticate the token using a header, I got back invalid token because I didnt specify the decode algorithm
@PulkitKumar191
@PulkitKumar191 7 жыл бұрын
Great tutorial. Thanks!
@prettyprinted
@prettyprinted 7 жыл бұрын
Thanks, I appreciate it!
@fahrican9708
@fahrican9708 4 жыл бұрын
great video thanks!
@george4061
@george4061 Жыл бұрын
thank you sir!
@gggal123
@gggal123 5 жыл бұрын
Awesome Awesome Awesome Awesome Awesome Awesome Awesome tutorial.
@code_tech01
@code_tech01 Жыл бұрын
Thanks to explain
@r5bc
@r5bc 4 жыл бұрын
Hi, very helpful video. Please can you put the link to the video that follows this one in this flask api cours ?
@nicolascorrea1989
@nicolascorrea1989 4 жыл бұрын
you're the best !
@abhaychinchole3482
@abhaychinchole3482 3 жыл бұрын
i am getting invalid token despite of copying the token...help will be appreciated
@selman8653
@selman8653 Жыл бұрын
Thanks mate
@eriklee1131
@eriklee1131 5 жыл бұрын
Great video!
@prettyprinted
@prettyprinted 5 жыл бұрын
Thanks for watching!
@Maslacak1985
@Maslacak1985 2 жыл бұрын
any guess with : RuntimeError: Working outside of request context. This typically means that you attempted to use functionality that needed an active HTTP request. Consult the documentation on testing for information about how to avoid this problem.
@paballo694
@paballo694 Жыл бұрын
Did you manage to solve this?
@sosajacobb7973
@sosajacobb7973 Жыл бұрын
when returning decorated make sure its return decorated, not return decorated()
@raghu11220
@raghu11220 4 жыл бұрын
Nice man.. your doing great job.. its possible to make video on Keycloak with flask or django.. looking forward to hear from you
@ayyapanr
@ayyapanr 5 жыл бұрын
Great Tutorial! Works on the browser and postman.. but when I try Python3 requests, I get 401 back.. wireshark captures look similar.. anyways do we need to consider some encoding when we use Python3 clients?
@prettyprinted
@prettyprinted 5 жыл бұрын
You may have to. I'll have to test this out with calling from Python.
@danielfernandomurciaperdom7665
@danielfernandomurciaperdom7665 4 жыл бұрын
thank you so much
@robertwoodard8462
@robertwoodard8462 3 жыл бұрын
The jwt decode always throws an exception to token is invalid. It's passing the correct token, checked with a print, but it doesn't seem to like it. *UPDATE* you now have to pass the algorithm to decode the jwt token with as a list
@robertkl5261
@robertkl5261 2 жыл бұрын
thank you very much, had the same error and your comment saved me a lot of time :)
@animeshmisra5387
@animeshmisra5387 Жыл бұрын
Thanks! man
@satriyaningjagat
@satriyaningjagat Жыл бұрын
data = jwt.decode(token, app.config['SECRET_KEY'], algorithms= ['HS512', 'HS256'])
@TusharBhut-mk6mn
@TusharBhut-mk6mn Жыл бұрын
Can you make video on individual authentication for user and admin, where user authorized can use only [GET] method, while admin authorized can use [crud] methods.
@fly50789
@fly50789 Жыл бұрын
I am not sure about what is the different about flask-jwt-extend and flask-login? Which is better?
@petrk.4901
@petrk.4901 4 жыл бұрын
Hello, I would like to thank you for the videos you make are very beneficial for me. I wanted to ask you if you could create user roles using token_required. In this video, you used the feature only to reveal content for the logged-in user. Couldn't the functionality be extended to user roles? For example, Admin would have read, write, user read only, or other read only for some content. I want to create user roles. Thank you
@SanuKumar_addicted_brat
@SanuKumar_addicted_brat 3 жыл бұрын
Thanks for sharing such a great video, can you also help me with the logout?
@hsz7338
@hsz7338 5 жыл бұрын
Thank you for putting amazing tutorials together. I was wondering if you could make a video on Flask or Flask_restplus uses Oauth2? Thank you.
@prettyprinted
@prettyprinted 5 жыл бұрын
I'll consider that. Thanks for the idea and for watching.
@rienadetrof6198
@rienadetrof6198 5 жыл бұрын
Hello , how do you get the pop up to sign in? Great video btw!
@LatinDanceVideos
@LatinDanceVideos 4 жыл бұрын
this is the section of code that generates the pop box to sign in. maybe try using chrome incognito window. as the standard chrome caching introduces confounding behaviour. def login(): print("def login()") auth = request.authorization print("auth:", auth)
@mrsterbenblack9270
@mrsterbenblack9270 5 жыл бұрын
Very nice.
@prettyprinted
@prettyprinted 5 жыл бұрын
Thanks for watching!
@hrishinani
@hrishinani 2 жыл бұрын
Hi very clean explanation of the code but I'm unable to get output due to this line try: data = jwt.decode(token, app.config['SECRET_KEY']) any resolution for this please...
@jacksonjegatheesan5045
@jacksonjegatheesan5045 4 жыл бұрын
hi nice tutorial by the way how would i log out and how can i send login credentials from my front end
@KotoFF4ik
@KotoFF4ik 3 жыл бұрын
Awesome
@Kinyanjui_765
@Kinyanjui_765 2 жыл бұрын
hey if you see this...can make a video about how you can link this up with vanilla javascript? thank you
@madhavparikh9653
@madhavparikh9653 4 жыл бұрын
Really liked the explanation !!!. Still, it directly not verified and does not display any prompt to enter username and password. Anyone know why?
@KillerCookie
@KillerCookie 4 жыл бұрын
Thanks for a great tutorial! However, the link to the code seems to be broken, might want to fix it.
@Brunovtf
@Brunovtf 3 жыл бұрын
Can you add LOGOUT route? For cleaning the Token
@anusham4559
@anusham4559 5 жыл бұрын
I am new to python and its Very helpful. Can you let me know how to pass a parameter to 'protected' function along with token?
@prettyprinted
@prettyprinted 5 жыл бұрын
Could you be more specific? What are you trying to accomplish?
@anusham4559
@anusham4559 5 жыл бұрын
never mind. I got it working. I actually had an input parameter to the function and passing token along with input parameter was not working. But the issue was I was not calling it properly. Its working now. Thanks!
@twishasahay3178
@twishasahay3178 2 жыл бұрын
Hi i dont know why but the auth =request.authorization is not working for me. I am not getting the notification to fill in the username/password. I am getting the could not verify response. do i have to install any library other than the ones mentioned in the video or change any settings
@danieldaschle
@danieldaschle 7 жыл бұрын
THANKS
@prettyprinted
@prettyprinted 7 жыл бұрын
You're welcome! Thanks for watching.
@ambeshsingh1251
@ambeshsingh1251 6 жыл бұрын
very nice video. After hiting the login url for the first time it asks for username and password but after that it does not ask for it and directly gives the token. can u help me how it should ask for user-id and password everytime login API is hit..
@FlexThoseMuscles
@FlexThoseMuscles 6 жыл бұрын
I encountered problems while running, it always says no module name jwt so I did steps below: make sure to upgrade flask to the last version with : pip3 install flask uninstall jwt with: pip3 uninstall jwt install pyjwt with: pip3 install pyjwt
@FlexThoseMuscles
@FlexThoseMuscles 6 жыл бұрын
thanks for the like! Our teacher is sending his students on your tutorial (see: jberger.org/ on the twitter feed). Best luck with the premium courses and the tutoring.
@Ekosusiloharjo
@Ekosusiloharjo 5 жыл бұрын
Hi Anthony Get the code here not found
@kingleo188
@kingleo188 3 жыл бұрын
Thank you very much for the great video, Very well explained. Although I have stumbled at 17:49, Even though I have added the token in the URL, I got a "token is invalid" json response, Please help, I have gone through and copied your code as it is, But not sure where I went wrong.
@gustavocarnaval6622
@gustavocarnaval6622 3 жыл бұрын
Try to specify the algorithm on the decode function of JWT.
@selimduvakl6807
@selimduvakl6807 2 жыл бұрын
ı have the same problem. Did you be able to solve it?
@ComputerScience101
@ComputerScience101 5 жыл бұрын
Hi , I have created database using sqlite, how do i access the data here for credentials
@rizwanrizwan4176
@rizwanrizwan4176 5 жыл бұрын
how can i validate the different type of user like admin can view everything but user must restricted to see something? and also how to write security code for form data ?
@asgaraliyev8740
@asgaraliyev8740 4 жыл бұрын
is that request being restful request by the secret key now?
@fogcc1015
@fogcc1015 Жыл бұрын
but how automatically pass this token in all request ? Is that THE question !!!
@kmishy
@kmishy 2 жыл бұрын
Great explanation sir but title is misguiding because you have not used any API
@castro_hassler
@castro_hassler 4 жыл бұрын
What is the difference between doing this, and using the flask session object?
@castro_hassler
@castro_hassler 4 жыл бұрын
Just in the first case the clients does manage the request token to access the server, and in the other case the server allows a client based on a Cookie session, which one is better? Scalability seems to be in troubles when the server is the one who manage the permissions 'cause it has to maintain a state, but when is it a good idea to use, I mean the flask session object ¿
@____R__
@____R__ 5 жыл бұрын
After hitting login api for first time it asks for username and password. But after that it does not ask and direct given new token . Can u help me how it should ask userid and password every time login api is hit.
@animeshmishra4282
@animeshmishra4282 3 жыл бұрын
If i am making a website that uses this api but i want users to surf the website but not that api then what should i do ? 😩
@MegaFeel1
@MegaFeel1 4 жыл бұрын
Hey bro! But where is the code from this video? "Get the code here" page give me 404 error
@Coristo05
@Coristo05 4 жыл бұрын
Hi, i've got problem with request.authentication cause it's NoneType object. How should I fix it?
@corollayanki
@corollayanki 3 жыл бұрын
it's request.authorization, but you probably figured that out by now.
@surajthapa5688
@surajthapa5688 2 жыл бұрын
Can anyone provide a link for a next video please?
@lovneetchugh8063
@lovneetchugh8063 3 жыл бұрын
I am getting this error return jsonify({'token' : token.decode('UTF-8')}) AttributeError: 'str' object has no attribute 'decode'
@FailedSquare
@FailedSquare 2 жыл бұрын
Read the error message. Its telling you token is already a string type. In his example, on an older version of jwt it returned a byte type. Which is why the decode was needed for his example. return jsonify({'token': token})
@anishupadhyay898
@anishupadhyay898 2 жыл бұрын
hi when with the valid token obtained from login page still I get the message as token is missing.. can someone please help me with this
@naveengoyal5243
@naveengoyal5243 6 жыл бұрын
Can you please help me, that how should I go to the protected view without copy pasting the token manually and only using the python code.
@prettyprinted
@prettyprinted 6 жыл бұрын
You can use the library requests and authenticate that way.
@aloysiusseow9774
@aloysiusseow9774 3 жыл бұрын
request.authorization does not show a pop up authentication on my web browser pls help!
@shivanshjayara6372
@shivanshjayara6372 2 жыл бұрын
why pop up window for login is not opening. Can any one please tell me that. Any html template needed for that?
@asimhafeezz
@asimhafeezz 4 жыл бұрын
is it flask-jwt installed?? becuz it says no library exists when i try to install jwt...
@corollayanki
@corollayanki 3 жыл бұрын
the package is called pyjwt, so you do: pip install pyjwt
@moiarmio4863
@moiarmio4863 4 жыл бұрын
how to use it own my website rather than local host ?
@mahdihoseyni3661
@mahdihoseyni3661 2 жыл бұрын
how can get refresh token in this case?
@milindchavan4329
@milindchavan4329 3 жыл бұрын
this video belongs to which play list ? coz i want cover the whole topic ? plz suggest #PrettyPrinted
@sunilsolanki5043
@sunilsolanki5043 2 жыл бұрын
how to pass token directly to another api?
@biunircloud6432
@biunircloud6432 4 жыл бұрын
Someone could share link the next video? Thanks
@sunilsolanki5043
@sunilsolanki5043 2 жыл бұрын
where the data variable is used?
@priteshthaker8340
@priteshthaker8340 4 жыл бұрын
Get the code link doesn't work
@georgegoldmanonyedikachijo9330
@georgegoldmanonyedikachijo9330 3 жыл бұрын
while trying to implement this i got TypeError: 'module' object is not callable Traceback (most recent call last) File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__ return self.wsgi_app(environ, start_response) File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app response = self.handle_exception(e) File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception reraise(exc_type, exc_value, tb) File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/lb/Documents/trie/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/home/lb/Documents/trie/application/admin/routes/auth.py", line 20, in unprotected token = jwt({'user': auth.username, 'exp': datetime.datetime.utcnow() + datetime.timedelta(minutes=30)}, app.secret_key) TypeError: 'module' object is not callable
@artisole3304
@artisole3304 3 жыл бұрын
same bro same error
@SwapnilSudhir47
@SwapnilSudhir47 6 жыл бұрын
Hi , I am trying to login in the first login function, but it is again showing the login popup, even after credentials. Please help
@prettyprinted
@prettyprinted 6 жыл бұрын
Even if you use the code I've linked to in the description?
@SwapnilSudhir47
@SwapnilSudhir47 6 жыл бұрын
Its done...found a different approach.
@ayah5896
@ayah5896 5 жыл бұрын
@@SwapnilSudhir47 I have got the same issue. Can you please tell me how did you solve it? Thanks
@SwapnilSudhir47
@SwapnilSudhir47 5 жыл бұрын
@@ayah5896 I might have forgotten what i was doing, but can you please check in the console network, what issue is there, I can help :-)
@uripeled2
@uripeled2 4 жыл бұрын
How the the token is saved?
@TheNorthRemember
@TheNorthRemember 6 жыл бұрын
Great tutorial, can you please give me the syntax theme
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks. I just use the default one in Sublime Text 3.
User Authentication in Flask App using JWT [ JSON Web Token ]
24:32
龟兔赛跑:好可爱的小乌龟#short #angel #clown
01:00
Super Beauty team
Рет қаралды 42 МЛН
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 117 МЛН
Ouch.. 🤕⚽️
00:25
Celine Dept
Рет қаралды 10 МЛН
НАШЛА ДЕНЬГИ🙀@VERONIKAborsch
00:38
МишАня
Рет қаралды 2,6 МЛН
Why you NEED JSON Web Tokens (JWTs) to secure your API 🔒
14:43
What Is JWT and Why Should You Use JWT
14:53
Web Dev Simplified
Рет қаралды 1,2 МЛН
Session Vs JWT: The Differences You May Not Know!
7:00
ByteByteGo
Рет қаралды 200 М.
JWT | What is JWT ? | JWT Explained in Tamil | Cheetah Media
24:22
Cheetah Media
Рет қаралды 24 М.
Difference between cookies, session and tokens
11:53
Valentin Despa
Рет қаралды 641 М.
Intermediate Flask Tutorial: Implementing JSON Web Tokens (JWT)
12:29
Please stop using px for font-size.
15:18
Coder Coder
Рет қаралды 199 М.
JSON Web Token Authentication in Flask-RESTX
24:10
Pretty Printed
Рет қаралды 7 М.
龟兔赛跑:好可爱的小乌龟#short #angel #clown
01:00
Super Beauty team
Рет қаралды 42 МЛН