ASP NET Web API google authentication
Вставка
- Опубліковано 6 лют 2025
- Text version of the video
csharp-video-tu...
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our UA-cam channel. Hope you can help.
/ @aarvikitchen5572
Slides
csharp-video-tu...
All ASP .NET Web API Text Articles and Slides
csharp-video-tu...
All ASP .NET Web API Videos
• ASP.NET Web API tutori...
All Dot Net and SQL Server Tutorials in English
www.youtube.co...
All Dot Net and SQL Server Tutorials in Arabic
/ kudvenkatarabic
In this video we will discuss
1. Benefits of social logins
2. Using Google authentication with ASP.NET Web API
Benefits of social logins
Registration is simple and easy. All they have to provide is their social login username and password and the user is registered with our application. This also means one less password to remember. When users don’t have to remember mulitple usernames and passwords to login to multiple web sites, there will be less failed logins. As you know remembering multiple usernames and passwords is definitely as hassle.
From development point of view, we do not have to write code to manage usernames and passwords. All this is done by the external authentication providers like Google, Facebook, Twitter, Microsoft etc.
Using Google authentication with ASP.NET Web API : When the user clicks "Login with Google" button, he will be redirected to Google login page. The user will then provide his Google credentials. Once the login is successful, the user will be redirected to our application with an access token, which is a proof that the user is successfully authenticated and our web application grants access to the protected resources.
To use Google account for authentication, we will have to first register our application with Google. For the steps to register your application with Google and enable google authentication please check the following article.
csharp-video-tu...
Thank you Venkat for helping me to get a job switch. You are the best 🙏🙏
Lots of respect to you
Dear Venkat, your commitment is second to none.Thank you so much.
Really it is very helpful lesson and easy to understand. Every week I am waiting for the lessons.Thank you sir.
Thank you very much for taking time to give feedback. This means a lot. I am very glad you found the videos useful.
I have organised all the Dot Net & SQL Server videos in to playlists, which could be useful to you
ua-cam.com/users/kudvenkatplaylists?view=1&sort=dd
If you need DVDs or to download all the videos for offline viewing please visit
www.pragimtech.com/order.aspx
Slides and Text Version of the videos can be found on my blog
csharp-video-tutorials.blogspot.com
Tips to effectively use my youtube channel.
ua-cam.com/video/y780MwhY70s/v-deo.html
If you want to receive email alerts, when new videos are uploaded, please subscribe to my youtube channel.
ua-cam.com/users/kudvenkat
If you like these videos, please click on the THUMBS UP button below the video.
May I ask you for a favor. I want these tutorials to be helpful for as many people as possible. Please share the link with your friends and family who you think would also benefit from them.
Good Luck
Venkat
Sure sir, I am already subscribed your channel long time ago :) , and I really thank you for sharing your valuable knowledge and excellent experience with every one. I appreciate your kind effort. I wish you all the best of success.
Thanks for share your knowledge with the world. Long life to you my friend.
Great explanation , please create a video on .NET Core Web Api
Excellent sir... Great Explanation for google authenticaion.
It is a great video. Thank you so much.
Woohoo! 32 minutes! You've compensated the long time away with this :) Thanks!
ne seri
For those meeting 401 unauthorized issue, there are some tips below when i also met these error in the process
1. When meeting the 401 unauthorized issue, Press F12 to open console page (Chrome)
2. Check which page you are accessing currently unauthorized
3. For example, my unauthorized page is in GoogleAuthentication.js, function isUserResgistered
I have some typo mistake when following the video such as headers --- I miss typing a 's' --> so that i get the response message result is email is null, HasRegistered is true and provider is Null.
try to find your typo mistake or just go to the text versionof this tutorial mentioned in the video description below and copy some of the important code
Good luck everyone!
Doing Revision...Thanks a lot, Venkat Garu
Wowwwww... We MUST enable Google+ API in order for authentication to work, many thanks!
The solution for #error=access_denied is:
1- Open (Tools) Tab
2- Choose (NuGet Package Manager)
3- Choose (Package Manager Console)
4- Execute this command in Package Manager Console (Install-Package Microsoft.Owin.Security.Google -Version 2.1.0)
Note:- The Solution taken from youtube comment by "Khaled Said "
Thank you 👍 This helped !!
Even after installing the package, I am still getting the same error
it's is very helpful thanks venkat
Learned a lot from you! Thank You :)
really great videos.. Its really very helpful... superb
Thank you sir.. 🙏🙏👌👌👌👌👌
10:11 Is there a way to handle the redirect in my Web Form Default.aspx.cs file? Having the redirect happen in my protected void Button3_Click(object sender, EventArgs e) method?
Thank you so much. Awesome explanation you are great sir !!!
10:50 instead of going to the URL, use Telerik Fiddler, Tools
TextWizard... if you've copied the text, Fiddler will already have it
pasted in the wizard for you. Set the transform to URLDecode and enjoy
:)
hi, Thank you a lot! my website is not MVC, I don't havr a app_start folder? where my code should be written?
Hello sir Can you please show me an example on how to create and edit a user in google console or google workspace with C sharp
For those who get 404 error, I also got the same error. If you see at the bottom of the browser there is warning ' Do you want to open or save ExternalLogins.json (165 bytes) from the localhost?'. Click on Open button to open this file and you will find the url information there.
Thank you
for all who got 401 unauthorized error just add allowanonymous or remove authorize attribute of actioncontroller.. everything works fine for me.. thanks kudvenkat!
@kudvenkat sir
do i need to create account controller and externallogins OR just replace port number from url i get this that xml page please help ,me ???????
Hey, venkat very useful tutorial I am wondering can I use the same one for PayPal login?
Yes, I would make a google login by myself thanks to Venkat :))))
the Login with Google button redirects me to Login page again instead of data
any help ?
Great
How can I adapt this to .net core ?
Sir, the content is not working with google's OAuth2.
I am getting 401 for ajax request to url: '/api/Account/UserInfo' in isUserRegistered method.
can anyone help please??
has any Github repository link or source code available for this tutorial?
When I tried to implement this in asp.net Web API and angular framework am getting error as redirect uri mismatch can you please help me to resolve this issue
After creating getAccessToken() method when I am trying to log in with 'Login with Google' button. I'm not routing to 'Data.html' page. Though, Login page will open and token will be generated. But actually it should get inside Data.html and load the data but that's not happening.
Fixed. If you're finding a similar issue 'enable' Google-API domain as well.
Implement LDAP Authentication also
will Startup.Auth.cs like files created automatically in the project??
How can i do it using postman, because i get a token from google and i want to do it in postman because i am doing authorization from my mobile app of google.
Did you by any chance encountered 'AccessDenied' error after supplying the google credentials. I am having this error and not finding a workaround.
@@joshmann8022 Did you resolve this?
@@miraj0072004 No I couldn't. I moved on to the next tutorials but from what I read it seems like Google discontinued support due to security.
Do let me know if you find a way around it!
@@joshmann8022 That's tough...I myself am trying to do the same w.r.t Facebook. I have obtained a token and trying to check whether the user is registered in the internal database by calling "api/Account/UserInfo" with the token...but keep getting "Authorization has been denied for this request"
Hi, how can I use googleIDToken for authentication, generated from an android app in the webapi ?
Sir pleas if you could create this tutorial for Asp.net core 3 Web API
sir i want to implement this in simple asp.net web forms plz sir help me what should I do......
ThankYou soo much Sir...
Hello, Thank you very much for the tutorial. Do you have tutorials explaining REST services using Web API?
Thank you very much
hey venkat when i hit localhost:50422/api/Account/ExternalLogins?returnUrl=%2F&generateState=true. its only return
/api/Account/ExternalLogin?provider=Google&response_type=token&client_id=self&redirect_uri=http%3A%2F%2Flocalhost%3A50422%2F
not returning state please help
api/Account/ExternalLogins?returnUrl=%2F&generateState=true is not working please help us with the solution as many of us have been facing the same kind of problem.
Can you please provide the code of the program?
In this situation, any authorized user can Delete/add employee if I added api of delete/add employee. How to prevent that?
hello, sir, my project is working on localhost but I m get an error when I switched on the domain (The requested document was not found on this server.)
I just followed the steps which is shown in video and able to login via google successfully
Hi Sir
In case we want to allow both manual registrations and social media, do we have to create two tables oe that can be managed from one table only?
thank you venkat sir.
i'm getting this error at web page
The resource cannot be found
Requested URL: /api/Account/ExternalLogins
Same problem
same problem
Yes, Same problem mate
same problem
same topic in need in Web forms
when i deploy to production google response code 500
,How can I solve this problem?
Same error .Any Solution for this?
When i am calling api/Account/ExternalLogins?returnUrl=%2F&generateState=true. i am getting "No HTTP resource was found that matches the request URI". can anyone please tell me what i did wrong
Check in which webstorage you are storing the Session and from which web storage you are trying to access the session variable. If both will be different then you cannot redirect properly.
Everything is working fine, But Data.html the user name shows as NULL
Can any one help me
Hello, Most of us have been having issues when we add api/Account/ExternalLogins?returnUrl=%2F&generateState=true to our link... It is not working... We would love if you have a fix to this problem
What exactly the issue that you're facing?
Hi Sir, Can you tell why call to GetExternalLoginInfoAsync() method returns null?
you might be calling the ExternalLogin from postman/fiddler, Please call "ExternalLogin" use the web page you created.
The reason behind this is the cookies are stored in the same browser but you are accessing from some other source like Postman/Fiddler.
hi sir your video is very Helpful for mi thank you so much sir :) please can you explain what is Dependency Injection ,and membership login in mvc ,facebook id & password through other website login
Hello @kudvenkat
Your videos are very good to learn things from scratch.
I am facing a problem. After successful login with google account, Page goes to API default URL 'localhost:2652/#error=access_denied'. Can you please tell me what I am doing wrong?
I'm getting the same error. Were you able to resolve it and if so, how? Your help is greatly appreciated.
got this error....
Authorisation Error
Error 401: invalid_client
The OAuth client was not found.
any one can help me out plz.
i have already mvc exists project but how to add on this external login?
When I call /api/Account/ExternalLogin it's returning 404 page not found. What have I missed?
did u get the way out of your query>if yes plz let me know
build your project before issuing the request
use api/Account/ExternalLogins?returnUrl=%2F&generateState=true instead of "/api/Account/ExternalLogin"
Thank you, sir
I did exactly the same, made sure project builds. I got stuck at 9:52 I am getting http404 all the time. I used /api/Account/ExternalLogins?returnUrl=%2F&generateState=true and /Account/ExternalLogins?returnUrl=%2F&generateState=true I also tried restarting iis application, and whole computer, but still the same http404, what can be wrong?
hello, I always have #error=access_denied instead of #access_tocken after login with google account. Could you help me
I have had similar problem. Check the codes related to the ""access_token"
I have got my solution to the similar problem. I am sharing with you in case it can help you.
ON GoogleAuthentication.js file, on getAccessToken function.
I had missed an equal(=) sign, so the token being sent was not right. Check the below statement, I missed the equal sign.
var accessToken = location.hash.split('access_token=')[1].split('&')[0];
Thank you so much sir! but i want to do that in basic ASP.NET i dont have "Provider folder" from where i find that file?
localhost:1753/#error=access_denied
getting above error
I'm getting the same error. Were you able to resolve it and if so, how? Your help is greatly appreciated
Is this the last video of the serie?
Dear sir , I am not getting Access token on the url while redirecting to my Login.html page. it redirects me on localhost:36041/#error=access_denied uri ..please sir help me out ...Thank you so much
I'm getting the same error. Were you able to resolve it and if so, how? Your help is greatly appreciated
Same here too... please if you are able to solve it please let's know
Hope you can do some videos on React.Js. Thanks!
hi sir i am getting an error 400 Bad Request when i run my code.
me too ! i also same error when i run my code
Please Sir record a video on the concepts that how to host an ASP.NET website on a web server along with an example database Please sir
I have a problem in accessing the email id. The permission screen was not shown to access the email id. Any help?
Even I'm facing the same problem.. Did you got the solution?
same problem
where can i get those dll files ? please help me.
hello sir give me download this tutorial link
I have one question. Kindly tell me why are you specifying the "content-type" header in the JavaScript method "IsUserRegistered" when it is a GET request and has no request body?
please define the concept of partial classes
If i clicked login with google button, login page redirect to google page, but i give username and password this access denied error occurs. localhost:56206/#error=access_denied
plz help me?
Kudvenkar sir can you please add MSBI Video as well
Great video. I observed one issue. When we logout from Data.html page and again click on Login with Google, it directly takes us to Data.html page without the need to re-enter the google credentials. It seems that when we logout from Data.html page, our 'accessToken' is cleared from the browser, however our google account is still logged in. So when we again click on Login with Google, the code "window.location.href = "/api/Account/ExternalLogin?provider=Google&response_type= . . ." still fetches us the url with token and the code redirects us to Data.html.
Can you please guide us how to fix this..
after logging in from google. I am redirected back to the default index page of web api, with #accessdenied appended to the url. please help
redirected url is something like localhost: port/accessdenied
have you solve this problem? I encountered the same
Ordiz Imbano no not solved yet.
this is frustrating coz I tried everywhere on the net and I havent found the answer. I tried updating my Nuget Packages but still failed.
Hello, if you need solution just update owin for google package
what did you do ? I'm getting the same error !
Hello sir, Thank you so much for this video,It is working really well for me when I am running it on localhost but its not working when I uploaded my website on web server(When i am clicking on Login with Google it is redirecting me to the index page).What should i do??
hi. i am great fan of your programing.i have some issue to add goolge analytic to add in my admin page.kindly make a video how to add google analytic graph in my admin panel.thankx
bite me
Hello sir please make a video for making multilingual website using dropdown list of languages with County flags.
This is not web API, you're using MVC 🤦
Hi Sir,
Please add a video for token based authentication in asp.net web api using database first approach.I really need this concept and how to implement token based authentication using database first approach.
i also google lot off but i can not find any solution for this so please please please please please .. sir add this video .
thanks in advance
i followed all of the step as it is describe in video but getting the same error while logging with google account.. it is redirected to this URL " localhost:50684/#error=access_denied " with error access denied..Please anyone could help me to resolve this issue?????
I have had similar problem. Check the codes related to the ""access_token"
I have got my solution to the similar problem. I am sharing with you in case it can help you.
ON GoogleAuthentication.js file, on getAccessToken function.
I had missed an equal(=) sign, so the token being sent was not right. Check the below statement, I missed the equal sign.
var accessToken = location.hash.split('access_token=')[1].split('&')[0];
@@imtiajahammad3586 Hey dear. Can you please tell me what is the GoogleAuthentication.js. where is it store. I can't find it
@@imtiajahammad3586 Thanks i got it form script folder. thanks dear
@@sandanuwan735Even I'm facing the same issue localhost:55989/#error=access_denied. I'm getting this before implementing of retrieving access token and tried updating Google package from package manager nothing worked. Any thoughts here
what to do if i have two seperate projects inside one folder i.e. one is WEB API project and other is normal MVC project through which i call the web API..... i'm getting confused ...
When redirect back to Login.html , error occurs at api/Account/UserInfo 401 unauthorizd. . What have I missed?
how to get the url which they are getting at 9:17 min
replay assp
Getting an error_access_denied error in my url after logging in, anyone had the same situation?
yes, i am getting the same error. Immediately after google signin i am getting like this ; localhost:58502/#error=access_denied......Please somebody help with solution
Yes i am also follow all of the step as it is describe in video but getting the same error while logging with google account.. it is redirected to this URL " localhost:50684/#error=access_denied " with error access denied
Hey my friend the solution is:
1- Open (Tools) Tab
2- Choose (NuGet Package Manager)
3- Choose (Package Manager Console)
4- Execute this command in Package Manager Console (Install-Package Microsoft.Owin.Security.Google -Version 2.1.0)
Hello Khaled , your are genius man. Thanks for your valuable response, i was stuck in same issue from many days but your solution really helped me , i got the solution , Thanks a lot man.
@@trafiksolits2413 You are welcome my brother. We are one family.
what happen when we deny the google authentication request and how to handle the user deny event.
How can I use the same procedure to authenticate from an android application?
Hi, Can someone tell me why is the redirecturi differs i.e when the app is registered in google, he specifies a redirectUri-localhost:xxxx/signin-with-google but after authenticating ,,user is actually redirected to data.html since it is specified in the redirecturi component of url. So my question is when is the AuthorizedURI comes under the picture redirect flow between application and google?
I Got localhost:2371/#error=access_denied error
I have had similar problem. Check the codes related to the ""access_token"
I have got my solution to the similar problem. I am sharing with you in case it can help you.
ON GoogleAuthentication.js file, on getAccessToken function.
I had missed an equal(=) sign, so the token being sent was not right. Check the below statement, I missed the equal sign.
var accessToken = location.hash.split('access_token=')[1].split('&')[0];
speech less
@kudvenkat the API/account/ExternalLogin API call works for me locally but not in the production environment. I am receiving a 500 response from the production server
@notanxiousanxiety Any solution for this Please?
@kudvenkat info variable in RegisterExternal() returns null always. Fix???
Even i'm facing the same issue. If u have a solution for this please lemme know
I am not able to get email address like you, can you help me please ?
After Login When i try to click loadEmployee i get Authorize has been denied for the Request why i am getting this error Any Reason
- via YTPak(.com)
Hi Shams,
Did you resolve this ? I have the same 'AccessDenied' error after I entered the google credentials and didn't get much on stack overflow.
If there is a quick workaround I'll appreciate it if you can share.
Thanks
hasRegistered always false ?
Why I'm "var info = await Authentication.GetExternalLoginInfoAsync();" in AccountController get null.............please help me............
Hi Protoss! Did you get the solution of your " var info = await Authentication.GetExternalLoginInfoAsync(); " problem. I am also having the same problem from many days.
My Client side is use angular2, so it's different port , I think is cookies can't be share.........
I use the same port with .net can be used
Is it working now?Not working for me
Lol