Just double check that you have the owinstartup class set properly in the web.config, and then breakpoint your OWIN setup and make sure it is actually firing when the website starts.
{
ClientId = clientId,
ClientSecret = clientSecret,
//In order to allow using different google providers on the front-end vs the back office,
// these settings are very important to make them distinguished from one another.
SignInAsAuthenticationType = Constants.Security.BackOfficeExternalAuthenticationType,
// By default this is '/signin-google', you will need to change that default value in your
// Google developer settings for your web-app in the "REDIRECT URIS" setting
CallbackPath = new PathString("/umbraco-google-signin/")
};
No effects...
My observations
It seems like the authorization goes well. Or almost. When I try to link my account, I successfully sign in. But when inspecting the network traffic I have these 3 entries:
1) Indicating that I signed in and redirect url seems right
This kind of error suggests to me that your Umbraco is not accepting the auth from Google, but I've seen it lie. It could be for a number or reasons, but I would check the claims being returned. Umbraco must have a "name" to create an account, and this is often labelled incorrectly. You can usually grab this by intercepting the SecurityTokenValidated notification event(I've included the openID version of this below, not sure how to access it for google auth). Check there is a claim with the label "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" and that it contains text that will create a valid login for Umbraco(i.e. no spaces, special characters). Then hook up to the autolinkup event, and check everything you can there. The code to activate it is this;
var autoOptions = new ExternalSignInAutoLinkOptions(true, "writer")
{
OnAutoLinking = AutoLinkUp
};
Then you can create this;
public void AutoLinkUp(BackOfficeIdentityUser curUser, ExternalLoginInfo loginDeets)
{
var userService = Umbraco.Core.ApplicationContext.Current.Services.UserService;
var contentService = Umbraco.Core.ApplicationContext.Current.Services.ContentService;
}
So I'd debug it like this...
If the Notification/security event fires, then it is returning and authing google, but the account creation is failing. Check the name, and other claims.
If the autoLinkUp fires, then check that the account is being created and debug from there.
If neither of these is firing, then your problem is a bad configuration, and I'd double check it, and then post a screenshot of the google config screen here for us to have a little poke.
I just tried adding your code. Must say - I'm not sure what I'm doing. The code runs and the event is attached but what to do with the autoOptions object?
And I just found this in the log:
Umbraco.Core.Logging.OwinLogger - Event Id: 0, state: Authentication failed
System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationHandler.
<AuthenticateCoreAsync>d__0.MoveNext()
Apologies Jesper, I was rushing to leave the office and had to omit some steps for brevity. The AutoOptions are part of the AuthenticationOptions for google, so basically the bit where you setup your client id, scopes, etc.. I am using openID, so I am not 100% sure of the code for google. But as well as the code I added above, you then add the AutoOptions to the SetExternalSignInAutoLinkOptions, this is the full code from my config section.
No worries, good luck with it all! I spent a week tearing my hair out trying to dissect how it was working, and ended up using the Umbraco source to trace the events. Never again...
I got the same error... and I got past it, but now I have a different error message that I am trying to solve...
By the way, the fix was, apparently, Google made a change that now requires your Google Developer Console to have the Google+ API to be enabled. That will fix the error we all are getting related to "?error=Access_denied".
Now, I am using version 7.4.1 and am seeing "The requested provider (Umbraco.Google) has not been linked to to an account" as an error when attempting to login. Anyone here can point me to any documentation or article that can help me solve this?
Umbraco 7.3.0 Identity provider - can't get Google OAuth to work
Hi,
I want to link a Google Account to my BackOffice User to enable authentication via Google.
What I've done is:
My Google app uses these settings:
In the owin startup class I added this line in the configure method:
When I click on the "Link Google Account" button on my profile I get redirected to /umbraco.
In fiddler I see this:
When I log out after that, the login page shows: "An error occurred, could not get external login info"
Hello Jan
I had this problem as well when first playing around with this stuff.
I tried it again on a clean solution and I believe it then worked for me, so try that as option first if you can.
But to verify my OWIN class I am using is
UmbracoStandardOwinStartup
that inherits fromUmbracoDefaultOwinStartup
But apart from me trying it again in a fresh install I can't remember what I done differently, but am happy to try to help you out.
Just double check that you have the owinstartup class set properly in the web.config, and then breakpoint your OWIN setup and make sure it is actually firing when the website starts.
Testing the same and run in to exactly the same problem
Google app is setup as this:
Authorized javascript origins : http://localhost Redirect uri : http://localhost/umbraco-google-signin
I've added
and changed web .config to point to UmbracoStandardOwinStartup
I've tried linking the logged in profile but it fails silently. Using Google Chrome inspect network i see some ?error=Access_denied
Ive tried loggin in from front but after putting in Google Credentials I'm redirected to
http://localhost/umbraco/?error=access_denied#/
Any advise?
/Jesper
So I tried adding a trailing / to the in the credentials config in the developer console
Redirect uri : http://localhost/umbraco-google-signin http://localhost/umbraco-google-signin/
Also tried adding it in the startup code:
No effects...
My observations
It seems like the authorization goes well. Or almost. When I try to link my account, I successfully sign in. But when inspecting the network traffic I have these 3 entries:
1) Indicating that I signed in and redirect url seems right
2)
3)
No clue how to get on from here. It seems that its in the final stage when receiving the token?
Oh btw - I just tested with Facebook authentication.
Works perfect! But I much rather use Google :-)
This kind of error suggests to me that your Umbraco is not accepting the auth from Google, but I've seen it lie. It could be for a number or reasons, but I would check the claims being returned. Umbraco must have a "name" to create an account, and this is often labelled incorrectly. You can usually grab this by intercepting the SecurityTokenValidated notification event(I've included the openID version of this below, not sure how to access it for google auth). Check there is a claim with the label "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" and that it contains text that will create a valid login for Umbraco(i.e. no spaces, special characters). Then hook up to the autolinkup event, and check everything you can there. The code to activate it is this;
Then you can create this;
So I'd debug it like this...
If the Notification/security event fires, then it is returning and authing google, but the account creation is failing. Check the name, and other claims. If the autoLinkUp fires, then check that the account is being created and debug from there. If neither of these is firing, then your problem is a bad configuration, and I'd double check it, and then post a screenshot of the google config screen here for us to have a little poke.
OpenID notification code;
HTH!!
Thanks Tony,
I just tried adding your code. Must say - I'm not sure what I'm doing. The code runs and the event is attached but what to do with the autoOptions object?
And I just found this in the log:
/Jesper
Apologies Jesper, I was rushing to leave the office and had to omit some steps for brevity. The AutoOptions are part of the AuthenticationOptions for google, so basically the bit where you setup your client id, scopes, etc.. I am using openID, so I am not 100% sure of the code for google. But as well as the code I added above, you then add the AutoOptions to the SetExternalSignInAutoLinkOptions, this is the full code from my config section.
Hey Tony,
Thanks for all your time. Dont apologies :)
I've added it as you specified but it seems that the Google Authentication configuration does not initiate the event at all.
I'm in over my head and I'll probably have to wait until it works "out of the box".
But thanks for you time and effort.
Jesper
No worries, good luck with it all! I spent a week tearing my hair out trying to dissect how it was working, and ended up using the Umbraco source to trace the events. Never again...
I got the same error... and I got past it, but now I have a different error message that I am trying to solve...
By the way, the fix was, apparently, Google made a change that now requires your Google Developer Console to have the Google+ API to be enabled. That will fix the error we all are getting related to "?error=Access_denied".
Now, I am using version 7.4.1 and am seeing "The requested provider (Umbraco.Google) has not been linked to to an account" as an error when attempting to login. Anyone here can point me to any documentation or article that can help me solve this?
Thanks, Jojo
I have found the solution to my problem here... https://our.umbraco.org/forum/developers/api-questions/73317-auto-create-and-link-backoffice-account
and here http://issues.umbraco.org/issue/U4-6753
Have you enabled Google Plus Api?
You have to enable the Google Plus API.
Exactly - this has to be enabled
is working on a reply...