Upon successful authentication redirection from "login?destination=oauth2/authorize" to the sign in page on "oauth2_login" there are Notices seen on the page.

Steps to reproduce:
1. Navigate to "/oauth2_login"
2. User is redirected to: "login?destination=oauth2/authorize"
3. Provide the user name and password
4. Login
Issue : There are Notices on the page.

Snapshot attached for reference.

CommentFileSizeAuthor
NoticeSSO.png15.74 KBavni09

Comments

avni09 created an issue. See original summary.

dashohoxha’s picture

It gives no notices for me. Check it here: https://l10n.org.al (and then click on login).

Hint: Look for the error on the module oauth2_loginprovider because that is the one that sends the user profile.
Another possibility can be the library hybridauth-drupaloauth2, used by hybridauth to get the user profile.

karthikkumarbodu’s picture

Status: Active » Fixed

The notice is from hybridauth module. Added a patch to fix the notice

Issue Link : https://www.drupal.org/node/2569349

avni09’s picture

Verified. No more notices appearing now :)
Thanks @dashohoxha and @karthikkumarbodu.

dashohoxha’s picture

One solution is to implement this hook on the server:

/**
 * Implements hook_oauth2_loginprovider_userprofile_alter().
 */
function SERVERMODULE_oauth2_loginprovider_userprofile_alter(&$data) {
  // Remove uninteresting fields.
  unset($data['uuid']);
  unset($data['rdf_mapping']);

  // Add the profileURL field.
  $path = drupal_get_path_alias('user/' . $data['uid']);
  $data['profileURL'] = url($path, ['absolute' => TRUE]);
}

And then implement this hook on the client:

/**
 * Implements hook_hybridauth_provider_config_alter().
 */
function CLIENTMODULE_hybridauth_provider_config_alter(&$hybridauth_config, $provider_id) {
  if ($provider_id != 'DrupalOAuth2')  return;

  if (!isset($hybridauth_config['profile_fields'])) {
    $hybridauth_config['profile_fields'] = array();
  }
  $hybridauth_config['profile_fields'] += array('profileURL' => 'profileURL');
}

Another solution is to support the field profileURL in the module oauth2_loginprovider itself, and in the library hybridauth-drupaloauth2. Which one do you think is better?

karthikkumarbodu’s picture

I feel the second solution is a precise one as the changes will be part of the contributed module and library.
New users don't need to implement the two hooks which you suggested.

dashohoxha’s picture

@karthikkumarbodu: Exactly, I totally agree with you.

@avni09: Sure, but it only hides the problem. The problem is that the field 'profileURL' is missing from the profile. Maybe this doesn't matter, but maybe the module hybridauth needs to use it, and an empty value is not good. I don't know the details of hybridauth (it is too big to study).

dashohoxha’s picture

Here are the patches that fix this issue:
- https://github.com/dashohoxha/oauth2_loginprovider/commit/4bc3bf259211fd...
- https://github.com/B-Translator/hybridauth-drupaloauth2/commit/78163cfcb...

There is also a new release (1.6) for the module oauth2_loginprovider that includes this patch.
For hybridauth-drupaloauth2 you have to make a `git pull` (and then copy DrupalOAuth2.php to the proper place in hybridauth).

dashohoxha’s picture

Status: Fixed » Active

I am leaving this issue open, because it somehow documents an undocumented feature of (oauth2_loginprovider + oauth2_login), namely that the application can modify the user profile as it likes (through using hooks).
I do this in my application for my needs, but the other people may not be aware of it.

karthikkumarbodu’s picture

Dear Dashamir, Please update the patch here as well

https://github.com/hybridauth/hybridauth/blob/master/additional-provider...

I can see you are the contributor of the Drupal OAUTH2 Provider.

dashohoxha’s picture

Yes I am, but I don't have commit access on the hybridauth repository on GitHub, so I don't know when it will be accepted, and when it will be included on a stable release of hybridauth. So, you better don't rely on that repo, just use the one that I can manage myself.

If you want you can submit a patch for it and be a maintainer of it (just sync it with my repo). But I am not going to do it.

I was once a maintainer of hybridauth, had disagreements with other maintainers about how it should be managed, and then I left. My opinion is that each contributed provider module is better maintained and managed in its own separate repository, having its own releases, maintainers (with commit rights), and so on.

karthikkumarbodu’s picture

Yes i agree with you about maintaining separate repositories for contributed providers. I will not create a PR with the new changes. I will rely only on your repository.