After successfully creating and/or connecting an account with Google or Facebook there's no data imported to the user profile. Here is the exported code of my Google connector:

$provider = new stdClass();
$provider->disabled = FALSE; /* Edit this to true to make a default provider disabled initially */
$provider->name = 'google';
$provider->title = 'Google';
$provider->url = 'https://accounts.google.com';
$provider->consumer_advanced = array(
  'oauth2' => 1,
  'signature method' => 'HMAC-SHA1',
  'authentication realm' => 'authorization_code',
  'request token endpoint' => 'none',
  'authorization scope' => 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email',
  'authorization endpoint' => '/o/oauth2/auth',
  'access token endpoint' => '/o/oauth2/token',
);
$provider->mapping = array(
  'fields' => array(
    'uid' => array(
      'resource' => 'https://www.googleapis.com/oauth2/v1/userinfo',
      'method post' => 0,
      'field' => 'id',
      'querypath' => FALSE,
      'sync_with_field' => '',
    ),
    'email' => array(
      'resource' => 'https://www.googleapis.com/oauth2/v1/userinfo',
      'method post' => 0,
      'field' => 'email',
      'querypath' => FALSE,
      'sync_with_field' => 'mail',
    ),
    'name' => array(
      'resource' => 'https://www.googleapis.com/oauth2/v1/userinfo',
      'method post' => 0,
      'field' => 'name',
      'querypath' => FALSE,
      'sync_with_field' => 'name',
    ),
    'avatar' => array(
      'resource' => 'https://www.googleapis.com/oauth2/v1/userinfo',
      'method post' => 0,
      'field' => 'picture',
      'querypath' => FALSE,
      'sync_with_field' => 'picture',
    ),
  ),
  'format' => 'json',
);

Additionally I get these errors when saving a new connector:
Notice: Undefined property: stdClass::$csid in oauthconnector_provider_save() (line 461 of /home/s080feb3/public_html/d7/sites/default/modules/oauthconnector/oauthconnector.module).
Notice: Undefined property: stdClass::$csid in oauthconnector_provider_save() (line 462 of /home/s080feb3/public_html/d7/sites/default/modules/oauthconnector/oauthconnector.module).

Great module by the way, just need it to work!

Comments

Assigned:nonozz» Unassigned

Priority:Critical» Normal

Status:Active» Postponed (maintainer needs more info)

What data do you mean?

The mapping of the fields is a pain in the ...
Basic fields as email and username should work.

I'm afraid I'm talking about that pain in that place.. none of the mapped fields gets filled after connecting/creating an account, guess it's related to that 'Notice: Undefined property'

Does 'sync local profile with PROVIDERNAME' do something on:
user/1/connections ?

If not, did you map fields on the aouthconnector provider config?
'Field to match on user profile'

Yes and yes, connected accounts does appear on the user profile tab and I have mapped the fields in the config.. even tried different combinations of default and custom fields but didn't get any data.

I'm running Drupal 7.12 minimal profile install with the necessary modules only.

can you export the provider and dump it here?
admin/structure/oauthconnector

Also like to know what kind of fields (text, username...) you are trying to fill.

I've tried mapping with the preset's default fields and also with just a custom text field mapped to the username, no succeed. When creating a new account the resulting profile is empty, no email, no picture, nothing in the custom field, nothing at all but the username which is something like 'oauthconnector_google__10533...'

Here is the exported provider:

$provider = new stdClass();
$provider->disabled = FALSE; /* Edit this to true to make a default provider disabled initially */
$provider->name = 'google';
$provider->title = 'Google';
$provider->url = 'https://accounts.google.com';
$provider->consumer_advanced = array(
  'oauth2' => 1,
  'signature method' => 'HMAC-SHA1',
  'authentication realm' => 'authorization_code',
  'request token endpoint' => 'none',
  'authorization scope' => 'https://www.googleapis.com/auth/userinfo.profile',
  'authorization endpoint' => '/o/oauth2/auth',
  'access token endpoint' => '/o/oauth2/token',
);
$provider->mapping = array(
  'fields' => array(
    'uid' => array(
      'resource' => 'https://www.googleapis.com/oauth2/v1/userinfo',
      'method post' => 0,
      'field' => 'id',
      'querypath' => FALSE,
      'sync_with_field' => '',
    ),
    'name' => array(
      'resource' => 'https://www.googleapis.com/oauth2/v1/userinfo',
      'method post' => 0,
      'field' => 'name',
      'querypath' => FALSE,
      'sync_with_field' => 'field_nombre',
    ),
    'avatar' => array(
      'resource' => 'https://www.googleapis.com/oauth2/v1/userinfo',
      'method post' => 0,
      'field' => 'picture',
      'querypath' => FALSE,
      'sync_with_field' => 'picture',
    ),
  ),
  'format' => 'json',
);

Project:OAuth Connector» Connector
Status:Postponed (maintainer needs more info)» Needs review

I did some work on the mapping of the fields.

This is a connector thingie and not a oauth connector thingie.

The default action now maps email and name to the right fields on first login. Please read carefully... it only maps mail and name and only on first login .
So... it does not do anything with avatar or other fields (yet).

The functionality 'sync local profile with PROVIDERNAME' does also a better job now. Normal text fields are all mapped now, images and other fields not.

What now... or how to solve...

  • You can take a look at the sub module (of connector) connector_action_default_register_form.module to write your own custom behavior after a connection is made.
  • Or write a patch for connector so that the default action does its job.

When writing patches, please also see and try to team up:
#1450664: Prefill user form patch
#1481574: Integration with feeds

This patch adds additional fields on account creation (it uses entity metadata wrappers, which means it should work for most user profile entity fields but also requires the entity api module).

It definitely needs some more work and this may not even be the right approach, but I needed a solution for this and thought I'd share what I had in case it helps with progress.

Thanks remydenton for your patch, following yout work I've added support for importing link fields and address fields.

Please note that this requires patch #10 to work:

--- connector.module.orig 2014-01-25 11:49:36.000000000 +0100
+++ connector.module 2014-01-25 19:43:23.000000000 +0100
@@ -490,12 +490,45 @@
       if (module_exists('entity')) {
         $user_w = entity_metadata_wrapper('user', $new_account);
-        foreach ($info as $field) {
+        foreach ($info as $key => $field) {
           if (isset($field['sync']) && $field['sync'] && !in_array($field['sync'], $allowed_fields)) {
             if (!empty($field['value'])) {
               try {
+ if ($user_w->{$field['sync']}->type() == 'field_item_link') {
+   // Field type link
+   $user_w->{$field['sync']}->url->set($field['value']);
+ }
+ if ($user_w->{$field['sync']}->type() == 'addressfield') {
+   // Address field
+   if ($key == 'first_name') {
+ $user_w->{$field['sync']}->first_name->set($field['value']);
+   }
+   elseif ($key == 'last_name') {
+ $user_w->{$field['sync']}->last_name->set($field['value']);
+   }
+   elseif ($key == 'location') {
+     $point = geocoder('google', $field['value']['name']);
+ foreach ($point->data['geocoder_address_components'] as $cmp) {
+   if (in_array('locality', $cmp->types)) { // Bologna
+ $user_w->{$field['sync']}->locality->set($cmp->short_name);
+   }
+   elseif (in_array('administrative_area_level_2', $cmp->types)) { // BO
+ $user_w->{$field['sync']}->administrative_area->set($cmp->short_name);
+   }
+   elseif (in_array('country', $cmp->types)) { // IT
+ $user_w->{$field['sync']}->country->set($cmp->short_name);
+   }
+   elseif (in_array('postal_code', $cmp->types)) { // IT
+ $user_w->{$field['sync']}->postal_code->set($cmp->short_name);
+   }
+ } // rof
+   }
+ }
+ else {
+   // Other field types
                 $user_w->{$field['sync']}->set($field['value']);
               }
+              }
               catch (EntityMetadataWrapperException $e) {
                 watchdog('connector', 'Unable to set field %field_name on new user profile: %message', array('%field_name' => $field['sync'], '%message' => $e->getMessage()), WATCHDOG_NOTICE);
               }

StatusFileSize
new2.16 KB

Another patch along the same lines, except this one actually makes Entity a dependency.

I've turned the $allowed_fields into $unique_fields so it will still check if the username or email address is already in use, but otherwise all other fields will be inserted as per the EntityMetaDataWrapper.

Might need some additional checks to make sure every type of field is being attached correctly, but definitely not with such specific checking as per #11.

StatusFileSize
new2.13 KB
new434 bytes

Minor fix, last minute optimisation accidentally broke the unique_fields stuff.

Why are you guys looking at 7.x-1.0-beta1?
I can't even find that version to test the patch.
Just thought that new patches would apply on the latest versions.

Version:7.x-1.0-beta1» 7.x-1.x-dev

We're no (well, I'm not), I just didn't update the issue version.

#13 works fine, would love to see this committed!