Skip to content
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

scope issue causing 404 when returning... #186

Open
brettnzl opened this issue Jan 5, 2025 · 1 comment
Open

scope issue causing 404 when returning... #186

brettnzl opened this issue Jan 5, 2025 · 1 comment

Comments

@brettnzl
Copy link

brettnzl commented Jan 5, 2025

Hi, Ive tested this so far on 2 different websites, with new installs, and i am getting the same issue..

More or less here is what im doing, I have installed the plugin, I have the following options enabled:

image

I have the following setup in my Cloud:

image

Im using the following button shortcode:

<?php // Use home_url() to create the full path for the dashboard $dashboard_url = home_url('/account/'); echo do_shortcode('[google_login button_text="Login with Google" redirect_to="' . esc_url($dashboard_url) . '" /]'); ?>
When we hit google the url looks like this:

https://accounts.google.com/o/oauth2/auth/oauthchooseaccount?client_id={my client ID}&redirect_uri=https%3A%2F%2Fwebsite.com%2Fwp-login.php&state=eyJub25jZSI6IjFkM2VhNDM2M2MiLCJyZWRpcmVjdF90byI6Imh0dHBzOlwvXC9yZXN0YXJpZnkuY29tXC9kYXNoYm9hcmRcLyIsInByb3ZpZGVyIjoiZ29vZ2xlIn0%3D&scope=email%20profile%20openid&access_type=online&response_type=code&service=lso&o2v=1&ddm=1&flowName=GeneralOAuthFlow

This works fine when it goes back to the website the url looks like this:

https://website.com/wp-login.php?state=eyJub25jZSI6IjFkM2VhNDM2M2MiLCJyZWRpcmVjdF90byI6Imh0dHBzOlwvXC9yZXN0YXJpZnkuY29tXC9kYXNoYm9hcmRcLyIsInByb3ZpZGVyIjoiZ29vZ2xlIn0%3D&code=4%2F0AanRRruud25GHz0lg2KjyyS5Dh94E5_s2xPr_viLsT9PKhT2Bbm_oaOy-VTTXhzHEWsPcA&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+openid&authuser=1&prompt=none

This will cause a 404 Page.

However, if I remove this part:

+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile

Then it will work correctly. login, and create the user.

I can't find where this code is being generated... i thought it might be an encoding issue but it wasn't... it just seems to be the 2 google urls.

I don't even have these selected in the google cloud:

image

Can someone look if there is an issue here?

@brettnzl
Copy link
Author

brettnzl commented Jan 5, 2025

I was hoping someone would help here...

this is a temporarily work around which just replaces the part in the URL:

<?php
add_action('init', function () {
    // Check if the current request is for wp-login.php
    if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/wp-login.php') !== false) {
        // Parse the current URL
        $current_url = $_SERVER['REQUEST_URI'];

        // The part to be removed
        $remove_part = '+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile';

        // Check if the part to be removed exists
        if (strpos($current_url, $remove_part) !== false) {
            // Remove the unwanted part
            $new_url = str_replace($remove_part, '', $current_url);

            // Redirect to the cleaned URL
            wp_redirect(home_url($new_url));
            exit;
        }
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant