-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Google Auth- Asp.net core 3.1 #18858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You're adding the wrong references. OWIN is not for Core. Follow the Core 2 or Core 3 instructions. |
Yes.. you are correct. That is what I also mentioned. |
OK, what error are you getting? Can we see your startup class (remove any secrets first) and your csproj |
Error what I am getting is -----The oauth state was missing or invalid.
StartupClass
|
Oh what browser are you using? |
Chrome- Ideally this should not be problem. I just checked on IE. same issue. |
Ah ok that rules out out the samesite changes chrome made. |
You're trying to combine things in a confusing way. You already have
So the simplified code looks like this:
Also, CallbackPath does not refer to an MVC endpoint, it's a path that's handled internally by the auth middleware. The default is "/signin-google". Identity provides its own MVC callbacks in the Account controller that are called after the middleware completes. Why are you trying to chang the token endpoint? Note That said, none of this explains your error message. Sharing a Fiddler trace would help track the affected fields. |
Yes code is tried for getting solution for the resolution of error. I can see state, redirect url, scope is correct. GET /o/oauth2/v2/auth?response_type=code&client_id=XXXXXX&redirect_uri=https%3A%2F%2Flocalhost%3A44361%2FAccount%2FExternalLoginCallback&scope=profile&state=CfDJ8MlYFAXWQwBGo4IKoVfdgvOLbG8GxfxMyGCK6-uEj2yQRZ8OWsMCkdjaZKZ5J3twa7rpsGkdTio6Ey5884X5ySTxHHLIWSTQlpZxoRd7C4Tbv78CuItmssnZI_j_EC3oVNNe1DwpzSAZsUDwZQgaygKe3Bk7gp0hL9ITBtqpkXpKgn_cridNbAOaeZKtS7qhjMd_83RjYApXeixa-yWhKebBqOyK52TsRs__ZeiJuJclxu9M1EPIyadjsmv2R8gMjlvbaN8BwHNh5lvCmFev2y4 HTTP/1.1 I can see its response passed as Again passed- another request - I can see external cookie is set properly. and passed to next request. but in asp.net server. I am getting exception at OnRemoteFailure = context => Since this is not handled, page is always blank. Now my doubt is on controller. as I can see lot of param passed, but I think that is handled by middle ware, before it reaches to call back. Below is my signature. [HttpGet] my redirect url is correctly reflected and it looks. /signin-google has nothing to do with it. Thanks and appreciate your help. Issue is not resolved yet. Regards |
You've set CallbackPath to |
Thanks for your hint. I take /signin-google is hardcoding, not a good practice... any way it worked. but now, I can see _signInManager.GetExternalLoginInfoAsync( ) is always returning null. |
It doesn't have to be
Enable the debug application logs to find out why. Sharing an updated version of your Startup would also be a good sanity check. |
There is something interesting going on. Below is truncated/tampered log. Log.--
Startup --
|
What was the response for the |
Microsoft.AspNetCore.Authentication.Google.GoogleHandler: Information: Error from RemoteAuthentication: The oauth state was missing or invalid.. but the interesting point, in both provider, Google and AzureAD- exception is going to below block.
|
These partial code samples are getting hard to keep track of without context. Can you share a complete sample as a github repo? |
Hello, https://github.com/kishorpise/18858 Regards |
What's with Startup1? It's not being used at the moment. Do you actually want to map remote accounts to local accounts, or only use remote accounts like AAD and Google? This could be simplified if you do not need local accounts and can remove Identity. AddAzureAD doesn't combine well with Identity because it tries to mange its own cookie. aspnetcore/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs Lines 128 to 129 in 3da1b10
Remove this line, SignInScheme is set automatically:
Move UseAuthentication from here to here. It needs the routing endpoints to be calculated before it can pick up their policies. Remove AAD's CallbackPath from config, or set it to The same for Google's CallbackPath. What's with all of these other config settings for Google? They're not being used for anything because the key names don't match. |
Thanks for your prompt reply. Answers for each and every point as below.
3)SignInScheme removed. This was placed after reading other blogs.
I am making changes and will get back to you. Regards |
Dear, Entire code is shared with you... this is not production code and we change as we do debug. only constant is configuration values and .net core framework along with port number. rest every thing is temporary to fix the issue. If you are just commenting log is not matching I wanted to know does it work on your side, with these configured values ? If AddOpenIdConnect is to be used, we should remove from documentation, atleast from microsoft site, ->> and are you sure as per the official documentation I have to use instead AddMicrosoftAccount of AddOpenIdConnect Thanks confusion. |
Yes, we have plans to replace AddAzureAD with something more flexible. It works for basic scenarios but it does not adapt well to other scenarios like yours.
AddMicrosoftAccount provides OAuth support for Microsoft Accounts (e.g. outlook.com or hotmail.com addresses). AddOpenIdConnect is the general purpose auth component that AddAzureAD is built on. Unfortunately I think you need more interactive support than we can provide through Github. Every indication so far is that this is a configuration issue and not a product issue so your next option is to contact Microsoft Support so they can help you set this up correctly. |
I read your thread carefully, I confirm this is product and documentation issue. AddAzureAD is going to be removed, so I should not be using this code, and there should not nuget updates for that. Sample link for download has netcoreapp2.1 Thanks for your suggestion to contact microsoft support. Regards |
Sorry if off-topic but I just stumbled upon this thread.
The problem was that I had |
I am having a similar problem with the callback not being handled for google login. Here is my sample code: https://github.com/thorkia/GoogleAuthTest I can get it to work in Node using Passport - but I would prefer my backend to be C# Here are the logs: And in Chrome I see the following error: |
Your AuthorizationEndpoint is wrong, it should point to Google's servers with this value:
|
@Tratcher That worked partially. Thank you. Now I am getting an error about cookie correlation: [18:01:53 INF] Request starting HTTP/2 GET https://localhost:5001/authentication/external/google-login |
Sharing a Fiddler trace is the best way to troubleshoot cookie issues. Also, turning the logs up to debug level. |
@Tratcher I have attached the debug logs and the Fiddler trace. I removed my clientId from the items |
Looks like you're stuck in a loop here... https://github.com/thorkia/GoogleAuthTest/blob/ee6dd36788269fab3c104623315abbb114f26a46/GoogleAuthTest.WepAPI/Startup.cs#L59 |
Also, that url format doesn't work here. |
@Tratcher That worked perfectly thanks! I had tried the Adding the I will update my Git sample. Feel free to use it as a simple sample! |
I stopped as there was no solution… now I would work again to see if it can be fixed.
Regards
Kishor
From: Edgar Lagonell Drayer <[email protected]>
Sent: Friday, August 7, 2020 5:03 PM
To: dotnet/aspnetcore <[email protected]>
Cc: kishorpise <[email protected]>; Author <[email protected]>
Subject: Re: [dotnet/aspnetcore] Google Auth- Asp.net core 3.1 (#18858)
I have the same problem and I cannot find the solution, in google I found that the problem is due to chrome, see the following photo:
[Error_Google]<https://user-images.githubusercontent.com/15655547/89688193-f6fa1280-d901-11ea-9fb0-d1681c20fa19.png>
Does someone know how to solve this problem?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#18858 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALRUELYSK3U5OGNQYUERANDR7RTY3ANCNFSM4KRBYBZQ>.
|
Can you share a fiddler trace file and your Startup config? |
I hope it can help ` public class Startup
|
The client isn't sending back the correlation cookie. Can you also share the fiddler trace for the prior request so we can see the cookies the server sent to the client? |
The truth is that I do not understand, what does that have to do with that I deactivate a flag from chrome and everything works correctly. It is the same code deployed on the server. This is the flag that you disabled and everything works: #cookies-without-same-site-must-be-secure |
Sorry, you need to go back one further. We need to see the request that redirected from android.quinielavirtual.com to accounts.google.com. |
Forgive me, here it is: |
This is from has the call from android.quinielavirtual.com and the following from google. |
The cookie is marked as The See our proxy docs https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-3.1. That will get your request scheme fixed up so your redirect_uri will be correct and your cookies will get the secure attribute. |
Hey .. Let me see .. I ca n see lot many emails… Just collecting it.
From: Edgar Lagonell Drayer <[email protected]>
Sent: Wednesday, August 12, 2020 5:46 PM
To: dotnet/aspnetcore <[email protected]>
Cc: kishorpise <[email protected]>; Author <[email protected]>
Subject: Re: [dotnet/aspnetcore] Google Auth- Asp.net core 3.1 (#18858)
Man, you're a crack, it works.
[Works]<https://user-images.githubusercontent.com/15655547/90071407-ca753a80-dcf5-11ea-98c9-80dc8eae971c.png>
I am logged in. :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#18858 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALRUEL5SSG4CY2NQG565JWDSAMEQXANCNFSM4KRBYBZQ>.
|
Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue. This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue! |
For Social outh integration, I am trying some simple implementation. I am always getting
The auth state was missing or invalid. There is no much documentation available.
I read the post. #6486
it looks its out dated and not true. when I just add nuget reference, I have yellow mark on owin and others. and If I see release date of Microsoft.AspNetCore.Authentication.Google, It looks its released recently. how ever in my case I get only error without any hint for such a simple usecase.
Any hint will be appreciated.
Regards
Kishor
The text was updated successfully, but these errors were encountered: