Just recently starting using IdentityServer4 (IS4) playing around with samples and so on.
I have a setup where run IS4 (using the included sample UI MVC) configured with Google as an external provider. I also have an API setup, as well as a client (MVC web app). When authenticating, and the user clicks “Google” in the “External Login” section, he/she is redirected to Google as expected. However, after supplying the username and password, I expected to the see Google consent screen, but instead I am redirected back to the consent screen in IS4. Why is that? Should the end user not give consent that his/her Google profile information is being accessed, on a page which clearly is from Google (i.e. HTTPS and Googles certificate)?
I acknowledge that since I am also requiring consent from the user to access my API I might end up with 2 consent screens (one for profile info from Google, and one for API access from my own IS4 configuration), but if I did not have an API in my setup and simply wanted to use IS4 in a federated setup to provide ID tokens, I would not have a need for the consent of my own API and thus would expect only to see the consent screen from my external providers (e.g. Google, Facebook, Twitter, etc.).
I have my external provider configured like this:
services.AddAuthentication()
.AddGoogle("Google", options =>
{
options.ClientId = "<my client id>";
options.ClientSecret = "<my client secret>";
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
});
Could someone please enlighten me 🙂
Thanks
2
Answers
You don’t have control when you redirect to external idp since it is a delegated authentication. I don’t know how Google have implemented their OAuth flows but the following might be reasons as to why consent screen is not shown:
RequireConsent
flag to false, but I would doubt you can do this in Google as a 3rd party OAuth client)From Google’ help:
So, what you need is to disable consent for your client in IdSrv and enable it in Google.
Additionally, as described in this answer,
As added by @Mike Wilcox:
There is a playground: https://developers.google.com/oauthplayground/ where you can test this out.
Click on the settings icon in the top right and then check the “Use your own OAuth Credentials” box to then enter your app creds. You can add scopes and test out there.