I don't think this is a particularly the right way to go, but it's not actually very hard to make at least slightly more useful usernames out of OAuth. For my purposes, it's critical that I can at least identify the user.

Forthcoming patch is better, at least for my needs, but I think the real solution probably requires some kind of username format with tokens.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Status: Active » Needs review
FileSize
964 bytes
1.13 KB

For this patch to work, there is also a small patch needed to connector. Attached here for convenience.

The connector patch is actually against the alpha; I hadn't noticed until just now that the -dev is actually quite a bit different. Not sure if that invalidates the patch or not.

voxpelli’s picture

Status: Needs review » Needs work

If you know that the external usernames are unique, as they are on eg. Twitter and Digg, you can use them as the user id:s on a connector. The user id doesn't have to be a number, just something unique that tells us which local user to log in. I used that approach when testing OAuth Connector with Digg: https://gist.github.com/759648 While the result wouldn't be as beautiful as in your patch, it would at least solve the problem of recognizing which users are which.

Names aren't required for a connector as they are purely for presentation purpose - so we can't rely on them. Names also doesn't have to be unique so if eg. two John Smiths logs in from LinkedIn the usernames would conflict with your patch.

I like the idea of usernames formatted by tokens - will look into it - as you say it would probably be the best solution.

Regarding difference between alpha and dev on drupal.org - I don't see any difference?

merlinofchaos’s picture

I've thought a little more about this, and I realize that what I care about is the actual username; but the $username variable ends up being used for the authname as well as the username. The two absolutely do not need to be the same thing, so I think there definitely needs to be some more thought applied to this.

voxpelli’s picture

The two should be separated - I agree.

iainhallam’s picture

Beginning to look at these Connector modules; I think usernames based on tokens would be a very nice way of doing things.

adumicic’s picture

Has there been any movement on this issue?

xamanu’s picture

Version: 6.x-1.0-alpha1 » 7.x-1.x-dev
Status: Needs work » Needs review
FileSize
1.74 KB
2.99 KB

I rerolled this patches for the newer dev branches of OAuthConntector and Connector module. I extended the patches a little bit:

* "authname" and "username" do not have to be the same anymore (username can be changed and it keeps working)
* Username gets generated based on the field specified on the OAuth Connector Provider configuration for "Name".
* If a username already exists a "_n" (with n as counting numbers) gets appended.

xamanu’s picture

Rerolled patch from #7 to avoid same problem as mentioned in #1813858: Redundant argument in some _oauthconnector_fetch_field function calls.