Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Xtremefaith

    (@xtremefaith)

    I’m pretty sure I could write a patch into this IF I can figure out where the email that was used is stored. When I debug the $oauth_identity I only get the provider and ID. And if I debug the $result_obj I get the following keys:

    kind, etag, gender, objectType, id, displayName, name, familyName, givenName, url, image, url, isDefault, isPlusUser, language, circledByCount, verified

    Is there not a way to get the email?

    Thread Starter Xtremefaith

    (@xtremefaith)

    Within get_oauth_identity() (in login-google.php) I added a scope parameter and set it to 'email', I also tried https://www.googleapis.com/auth/plus.profile.emails.read.

    Unfortunately neither of these work. I don’t understand why not from what I’ve read of Google’s documentation. While playing on the API Explorer it returned as expected but only when accessing my own account. This leads me to believe that when attempting through plugin perhaps it lacks permissions even though it was granted.

    I will keep attempting this because I need it for a couple sites both with Google and Windows, so any help would be really appreciated. Depending on what needs updated I may work directly with you to contribute changes so please let me know.

    Thread Starter Xtremefaith

    (@xtremefaith)

    It looks like if I just change login-google.php line:

    define('SCOPE', 'profile');

    to:

    define('SCOPE', 'https://www.googleapis.com/auth/plus.profile.emails.read');

    Now the plan is to use this in the wp-oauth.php file at the wpoa_login_user() process just after wpoa_match_wordpress_user(). How does this sound to you. Is this something that would not work for the direction of your plugin (if so I may need to just fork this and make my own custom updates).

    Please let me know your thoughts.

    Thread Starter Xtremefaith

    (@xtremefaith)

    Judging from this line you have no intentions of including emails in your plugin:

    $oauth_identity['email'] = $result_obj['emails'][0]['value'];
    // PROVIDER SPECIFIC: Google returns an array of email addresses.
    To respect privacy we currently don't collect the user's email address.

    Unfortunately without at least using it for the moment I don’t know how else you can compare against current users:

    function wpoa_match_wordpress_user_by_email($oauth_identity) {
        $userid = email_exists( $oauth_identity['email'] );
        $user = get_user_by('id', $userid);
        return $user;
    }
    $this->wpoa_match_wordpress_user_by_email($oauth_identity);

    If this is the case then I will likely just fork my own version in order to add this feature

    Also migrating this post to github for further development:
    https://github.com/perrybutler/WP-OAuth/issues/52

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Unable to match previous users’ is closed to new replies.