umbraco-community / umbraco-analytics

Google Analytics for the Umbraco CMS
40 stars 31 forks source link

Problem with Authorization #63

Closed youmnaHigagy closed 4 years ago

youmnaHigagy commented 4 years ago

Hello,

I get this when I click Authorize then Login With Google,

image

I can't figure out what am I doing wrong :(

abisohexacta commented 4 years ago

Hello,

I am having the same issue as @youmnaHigagy after clicking the Authorize button on the Settings section. Is there any possibility of getting this fixed?

Thanks in advance.

EVandevska commented 4 years ago

Hi, I am still getting this issue. Is there any change this will be solved soon?

darkogele commented 4 years ago

I'm also having this issue . Its annoying so much :( any chance we gonna get fix on this in near future ?

MayurDeore commented 4 years ago

This error is caused when you have provided wrong redirect url. You need to register redirect url in Google API console, or check if registered redirect url is correct. Also note that when you register redirect url in console, it takes time to get activated.

EVandevska commented 4 years ago

This error is caused when you have provided wrong redirect url. You need to register redirect url in Google API console, or check if registered redirect url is correct. Also note that when you register redirect url in console, it takes time to get activated.

Unfortunately, the package owners are the ones who can do this. So we can only wait.

JimBobSquarePants commented 4 years ago

Unfortunately, the package owners are the ones who can do this. So we can only wait.

Are you sure about this? I've never used the package but a cursory glance through the source indicates that the RedirectUri is configurable.

https://github.com/umbraco-community/umbraco-analytics/blob/1ea6ca3e832d8b28b98e5f3f199595b4ee440764/Analytics/AnalyticsConfig.cs#L59

Did anyone in the thread above actually log in with Google?

MayurDeore commented 4 years ago

Unfortunately, the package owners are the ones who can do this. So we can only wait.

Are you sure about this? I've never used the package but a cursory glance through the source indicates that the RedirectUri is configurable.

https://github.com/umbraco-community/umbraco-analytics/blob/1ea6ca3e832d8b28b98e5f3f199595b4ee440764/Analytics/AnalyticsConfig.cs#L59

Did anyone in the thread above actually log in with Google?

You are right, redirect URL can be configured from settings.config available in App_Plugins/Analytics folder.
For this plugin redirect uri is https://<umbraco_site_domain>/App_Plugins/analytics/backoffice/OAuthCallback.aspx.

Here is the sample settings.config file.

<?xml version="1.0" encoding="utf-8" ?>
<Analytics>
  <ClientId label="Client ID" description="This is the Client ID key from the Google API">206456221167-1a6npdlit92260gfaekomgon8cm0ratg</ClientId>
  <ClientSecret label="Client Secret" description="This is the Client Secret from the Google API">_LklwvmJC0EIkEprcRB4keQ_</ClientSecret>
  <RefreshToken label="Refresh Token" description="The refresh token used to acquire new access tokens. This is sensitive information."></RefreshToken>
  <RedirectUri label="Redirect Uri" description="This is url where client will get send after successful authentication.">https://localhost:44313/App_Plugins/analytics/backoffice/OAuthCallback.aspx</RedirectUri>
</Analytics>
EVandevska commented 4 years ago

Thanks @JimBobSquarePants and @MayurDeore . We'll try this.

darrenferguson commented 4 years ago

Hello - this does appear to be an issue with the package - which we are seeing too.

In the analytics back office dasboard - when you click to authorize the initial redirect is out to http://analytics-oauth.azurewebsites.net/callback/OAuth.aspx passing out the values from your configuration as mentioned by @JimBobSquarePants above.

it passes out clientstate (a guid) and Redirect Uri from your configuration.

What happens from there on - is blackbox to us - as we don't know what analytics-oauth.azurewebsites.net does - and can't see any source for it.

However - what appears to happen is that you click to enter the Google OAuth flow - using a client application ID that is set by the application at analytics-oauth.azurewebsites.net and after authentication the OAuth flow fails because the redirect_uri for that client application setup by the package author doesn't work.

So to resolve this, I think that the package author need to update the redirect_uri for their client application - maybe it has expired? unwittingly been changed etc etc.

@warrenbuckley any chance that you can comment? Is the site at analytics-oauth.azurewebsites.net still maintained, and who owns the client application registered with Google?

warrenbuckley commented 4 years ago

Hello all, I created this way way back in 2013 🙈

The Google API key may have expired that is used to help with the Google OAuth Flow. I know i had alot of help from @abjerner to help with the oAuth flow. I will have a poke around and see what I find.

darrenferguson commented 4 years ago

Thanks @warrenbuckley

warrenbuckley commented 4 years ago

OK luckily found the source code for this over on BitBucket & remembered my login credentials. The Git repo is set to deploy magically to the Azure website and looking at the horrible code I wrote back then, I had hardcoded the client, secret & rediretURI in some lovely .aspx WebForms page 🤮

I have updated this and allowed it to be configurable from AppSettings so nice & easy to override from Azure Portal now if it becomes a problem.

Looking at the Google Developer Console for the API it seems the http:// url is not allowed to be added as a redirect URI and it must be https://

So the redirect uri setting is sent as https and I have added a web.config rewrite rule to ensure the page when requested from the Umbraco backoffice redirects to https as well.

@darrenferguson are you able to give this a spin please & see if its been fixed?

darrenferguson commented 4 years ago

@warrenbuckley let me give it a shot! thanks.

warrenbuckley commented 4 years ago

Waiting

darrenferguson commented 4 years ago

@warrenbuckley sorry! paul has gone to lunch - he is going to give it a spin as soon as he is back.

prjseal commented 4 years ago

I can confirm it works now. I tested version 1.2 of the package in a clean install of umbraco 7.5.8

There is no need to change any of the settings in the config files, it works straight out of the box now.

Thanks for fixing it @warrenbuckley

I've attached a screenshot for proof of it working at this point. image

warrenbuckley commented 4 years ago

Thanks for the clarification. I didn’t have an install around setup for it.

prjseal commented 4 years ago

If anyone wants to see how to authorize, I made a little video.

https://moriyamalondon-my.sharepoint.com/:v:/g/personal/paul_moriyama_co_uk/ERl3B0FsqSlPo37kvZymYWQBPcHrmgwXzoburhCwpaaGDg?e=x9SXgJ